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 4698e45
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 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(feature = "indexmap")]
use configparser::ini::WriteOptions;

#[test]
#[allow(clippy::approx_constant)]
fn non_cs() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -243,8 +247,8 @@ 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(())
Expand Down

0 comments on commit 4698e45

Please sign in to comment.