From 4698e45b556fcb4cb360f702fd5d100ba474e872 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Wed, 24 Apr 2024 13:37:48 -0700 Subject: [PATCH] Fix the empty section test 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. --- tests/test.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test.rs b/tests/test.rs index a976962..d46c7b3 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -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> { @@ -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(())