summaryrefslogtreecommitdiffstats
path: root/tests/file_yaml.rs
diff options
context:
space:
mode:
authorDavid Orchard <if_coding@fastmail.com>2021-08-01 00:03:10 -0700
committerDavid Orchard <if_coding@fastmail.com>2021-08-15 10:31:58 -0700
commitcc0530a7716779f954b1756905a9f4ceb7eb6d62 (patch)
tree311b2ca44a282bbc629a08123f53a855cba38c1c /tests/file_yaml.rs
parent622efaca17256fb42dafc61c8df1f3037c1fb772 (diff)
Move order preservation under a feature gate
Diffstat (limited to 'tests/file_yaml.rs')
-rw-r--r--tests/file_yaml.rs32
1 files changed, 19 insertions, 13 deletions
diff --git a/tests/file_yaml.rs b/tests/file_yaml.rs
index 4b1c108..18e34ad 100644
--- a/tests/file_yaml.rs
+++ b/tests/file_yaml.rs
@@ -7,7 +7,6 @@ extern crate serde;
#[macro_use]
extern crate serde_derive;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
use config::*;
@@ -21,7 +20,7 @@ struct Place {
favorite: bool,
telephone: Option<String>,
reviews: u64,
- creator: LinkedHashMap<String, Value>,
+ creator: MapImpl<String, Value>,
rating: Option<f32>,
}
@@ -59,17 +58,24 @@ fn test_file() {
assert_eq!(s.place.telephone, None);
assert_eq!(s.elements.len(), 10);
assert_eq!(s.elements[3], "4".to_string());
- assert_eq!(
- s.place
- .creator
- .into_iter()
- .collect::<Vec<(String, config::Value)>>(),
- vec![
- ("name".to_string(), "John Smith".into()),
- ("username".into(), "jsmith".into()),
- ("email".into(), "jsmith@localhost".into()),
- ]
- );
+ if cfg!(feature = "preserve_order") {
+ assert_eq!(
+ s.place
+ .creator
+ .into_iter()
+ .collect::<Vec<(String, config::Value)>>(),
+ vec![
+ ("name".to_string(), "John Smith".into()),
+ ("username".into(), "jsmith".into()),
+ ("email".into(), "jsmith@localhost".into()),
+ ]
+ );
+ } else {
+ assert_eq!(
+ s.place.creator["name"].clone().into_string().unwrap(),
+ "John Smith".to_string()
+ );
+ }
}
#[test]