diff options
Diffstat (limited to 'tests/get.rs')
-rw-r--r-- | tests/get.rs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/tests/get.rs b/tests/get.rs index 43a126a..9cd6ecc 100644 --- a/tests/get.rs +++ b/tests/get.rs @@ -7,7 +7,6 @@ extern crate serde; #[macro_use] extern crate serde_derive; -use linked_hash_map::LinkedHashMap; use std::collections::HashSet; use config::*; @@ -108,7 +107,7 @@ fn test_get_scalar_path_subscript() { #[test] fn test_map() { let c = make(); - let m: LinkedHashMap<String, Value> = c.get("place").unwrap(); + let m: MapImpl<String, Value> = c.get("place").unwrap(); assert_eq!(m.len(), 8); assert_eq!( @@ -121,23 +120,28 @@ fn test_map() { #[test] fn test_map_str() { let c = make(); - let m: LinkedHashMap<String, String> = c.get("place.creator").unwrap(); - - assert_eq!( - m.into_iter().collect::<Vec<(String, String)>>(), - vec![ - ("name".to_string(), "John Smith".to_string()), - ("username".to_string(), "jsmith".to_string()), - ("email".to_string(), "jsmith@localhost".to_string()), - ] - ); + let m: MapImpl<String, String> = c.get("place.creator").unwrap(); + + if cfg!(feature = "preserve_order") { + assert_eq!( + m.into_iter().collect::<Vec<(String, String)>>(), + vec![ + ("name".to_string(), "John Smith".to_string()), + ("username".to_string(), "jsmith".to_string()), + ("email".to_string(), "jsmith@localhost".to_string()), + ] + ); + } else { + assert_eq!(m.len(), 3); + assert_eq!(m["name"], "John Smith".to_string()); + } } #[test] fn test_map_struct() { #[derive(Debug, Deserialize)] struct Settings { - place: LinkedHashMap<String, Value>, + place: MapImpl<String, Value>, } let c = make(); @@ -222,7 +226,7 @@ fn test_enum() { } #[derive(Debug, Deserialize)] struct Settings { - diodes: LinkedHashMap<String, Diode>, + diodes: MapImpl<String, Diode>, } let c = make(); @@ -255,7 +259,7 @@ fn test_enum_key() { #[derive(Debug, Deserialize)] struct Settings { - proton: LinkedHashMap<Quark, usize>, + proton: MapImpl<Quark, usize>, // Just to make sure that set keys work too. quarks: HashSet<Quark>, } @@ -271,7 +275,7 @@ fn test_enum_key() { fn test_int_key() { #[derive(Debug, Deserialize, PartialEq)] struct Settings { - divisors: LinkedHashMap<u32, u32>, + divisors: MapImpl<u32, u32>, } let c = make(); |