Skip to content

Commit

Permalink
Fix the empty section test
Browse files Browse the repository at this point in the history
Because these are coming from a HashMap, the order is not guaranteed.
The workaround is to put them into a HashSet and compare those so
order doesn't matter.
  • Loading branch information
belak committed Apr 24, 2024
1 parent 1f6f20c commit b4ed9ea
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use configparser::ini::{Ini, WriteOptions};
use configparser::ini::Ini;
use std::collections::HashSet;
use std::error::Error;

#[cfg(indexmap)]
use configparser::init::WriteOptions;

#[test]
#[allow(clippy::approx_constant)]
fn non_cs() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -243,8 +247,12 @@ basic_option=basic_value
config.read(FILE_CONTENTS.to_owned())?;

assert_eq!(
config.sections(),
vec![String::from("basic_section"), String::from("empty_section")]
HashSet::from_iter(config.sections().into_iter()),
HashSet::from([String::from("basic_section"), String::from("empty_section")])
);

Ok(())
}
);

Ok(())
Expand Down

0 comments on commit b4ed9ea

Please sign in to comment.