diff options
author | David Orchard <if_coding@fastmail.com> | 2021-07-28 22:49:48 -0700 |
---|---|---|
committer | David Orchard <if_coding@fastmail.com> | 2021-08-15 10:31:10 -0700 |
commit | 62c84297e5340d717d89c5c0b36ed86dd5ad9d2f (patch) | |
tree | e3062f57dfb10b921267aeeed5df6b42d93a4657 | |
parent | 74a0a809f642e2d212752c9ccb767d987c42302e (diff) |
Create test cases to demonstrate lossy map order
-rw-r--r-- | tests/Settings.hjson | 2 | ||||
-rw-r--r-- | tests/Settings.json | 4 | ||||
-rw-r--r-- | tests/Settings.json5 | 2 | ||||
-rw-r--r-- | tests/Settings.ron | 4 | ||||
-rw-r--r-- | tests/Settings.toml | 2 | ||||
-rw-r--r-- | tests/Settings.yaml | 2 | ||||
-rw-r--r-- | tests/file_hjson.rs | 11 | ||||
-rw-r--r-- | tests/file_json.rs | 11 | ||||
-rw-r--r-- | tests/file_json5.rs | 11 | ||||
-rw-r--r-- | tests/file_ron.rs | 11 | ||||
-rw-r--r-- | tests/file_toml.rs | 11 | ||||
-rw-r--r-- | tests/file_yaml.rs | 11 | ||||
-rw-r--r-- | tests/get.rs | 10 | ||||
-rw-r--r-- | tests/legacy/file_hjson.rs | 11 | ||||
-rw-r--r-- | tests/legacy/file_json.rs | 11 | ||||
-rw-r--r-- | tests/legacy/file_ron.rs | 11 | ||||
-rw-r--r-- | tests/legacy/file_toml.rs | 11 | ||||
-rw-r--r-- | tests/legacy/file_yaml.rs | 11 | ||||
-rw-r--r-- | tests/legacy/get.rs | 10 | ||||
-rw-r--r-- | tests/legacy/merge.rs | 14 | ||||
-rw-r--r-- | tests/merge.rs | 14 |
21 files changed, 151 insertions, 34 deletions
diff --git a/tests/Settings.hjson b/tests/Settings.hjson index 3e04ccf..9810e04 100644 --- a/tests/Settings.hjson +++ b/tests/Settings.hjson @@ -11,6 +11,8 @@ rating: 4.5 creator: { name: John Smith + username: jsmith + email: jsmith@localhost } } } diff --git a/tests/Settings.json b/tests/Settings.json index 001948d..babb0ba 100644 --- a/tests/Settings.json +++ b/tests/Settings.json @@ -11,7 +11,9 @@ "reviews": 3866, "rating": 4.5, "creator": { - "name": "John Smith" + "name": "John Smith", + "username": "jsmith", + "email": "jsmith@localhost" } } } diff --git a/tests/Settings.json5 b/tests/Settings.json5 index cfab1f5..4c93e42 100644 --- a/tests/Settings.json5 +++ b/tests/Settings.json5 @@ -13,6 +13,8 @@ rating: 4.5, creator: { name: "John Smith", + "username": "jsmith", + "email": "jsmith@localhost", } } } diff --git a/tests/Settings.ron b/tests/Settings.ron index 528fd61..7882840 100644 --- a/tests/Settings.ron +++ b/tests/Settings.ron @@ -12,7 +12,9 @@ rating: Some(4.5), telephone: None, creator: { - "name": "John Smith" + "name": "John Smith", + "username": "jsmith", + "email": "jsmith@localhost" } ) ) diff --git a/tests/Settings.toml b/tests/Settings.toml index bafb319..bb53808 100644 --- a/tests/Settings.toml +++ b/tests/Settings.toml @@ -41,6 +41,8 @@ rating = 4.5 [place.creator] name = "John Smith" +username = "jsmith" +email = "jsmith@localhost" [proton] up = 2 diff --git a/tests/Settings.yaml b/tests/Settings.yaml index c92fcb0..8e79c29 100644 --- a/tests/Settings.yaml +++ b/tests/Settings.yaml @@ -10,3 +10,5 @@ place: rating: 4.5 creator: name: John Smith + username: jsmith + email: jsmith@localhost diff --git a/tests/file_hjson.rs b/tests/file_hjson.rs index 4002a90..96fe8b1 100644 --- a/tests/file_hjson.rs +++ b/tests/file_hjson.rs @@ -60,8 +60,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/file_json.rs b/tests/file_json.rs index 4563e42..4e5edbc 100644 --- a/tests/file_json.rs +++ b/tests/file_json.rs @@ -60,8 +60,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/file_json5.rs b/tests/file_json5.rs index d22b726..0bf5138 100644 --- a/tests/file_json5.rs +++ b/tests/file_json5.rs @@ -59,8 +59,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/file_ron.rs b/tests/file_ron.rs index d60c890..c901419 100644 --- a/tests/file_ron.rs +++ b/tests/file_ron.rs @@ -62,8 +62,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/file_toml.rs b/tests/file_toml.rs index 9493bbd..7c57c4b 100644 --- a/tests/file_toml.rs +++ b/tests/file_toml.rs @@ -71,8 +71,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/file_yaml.rs b/tests/file_yaml.rs index 90feefc..2ea9db4 100644 --- a/tests/file_yaml.rs +++ b/tests/file_yaml.rs @@ -60,8 +60,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/get.rs b/tests/get.rs index c6030ae..99f9c84 100644 --- a/tests/get.rs +++ b/tests/get.rs @@ -122,8 +122,14 @@ fn test_map_str() { let c = make(); let m: HashMap<String, String> = c.get("place.creator").unwrap(); - assert_eq!(m.len(), 1); - assert_eq!(m["name"], "John Smith".to_string()); + 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()), + ] + ); } #[test] diff --git a/tests/legacy/file_hjson.rs b/tests/legacy/file_hjson.rs index 120bcc6..ecc5165 100644 --- a/tests/legacy/file_hjson.rs +++ b/tests/legacy/file_hjson.rs @@ -58,8 +58,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/legacy/file_json.rs b/tests/legacy/file_json.rs index e2300c6..0ad2c8c 100644 --- a/tests/legacy/file_json.rs +++ b/tests/legacy/file_json.rs @@ -58,8 +58,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/legacy/file_ron.rs b/tests/legacy/file_ron.rs index 91f88f3..912f654 100644 --- a/tests/legacy/file_ron.rs +++ b/tests/legacy/file_ron.rs @@ -60,8 +60,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/legacy/file_toml.rs b/tests/legacy/file_toml.rs index 2271962..13e3590 100644 --- a/tests/legacy/file_toml.rs +++ b/tests/legacy/file_toml.rs @@ -69,8 +69,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/legacy/file_yaml.rs b/tests/legacy/file_yaml.rs index 5d7a60f..930a6f7 100644 --- a/tests/legacy/file_yaml.rs +++ b/tests/legacy/file_yaml.rs @@ -58,8 +58,15 @@ fn test_file() { assert_eq!(s.elements.len(), 10); assert_eq!(s.elements[3], "4".to_string()); assert_eq!( - s.place.creator["name"].clone().into_string().unwrap(), - "John Smith".to_string() + 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()), + ] ); } diff --git a/tests/legacy/get.rs b/tests/legacy/get.rs index 48a7b43..fe11657 100644 --- a/tests/legacy/get.rs +++ b/tests/legacy/get.rs @@ -120,8 +120,14 @@ fn test_map_str() { let c = make(); let m: HashMap<String, String> = c.get("place.creator").unwrap(); - assert_eq!(m.len(), 1); - assert_eq!(m["name"], "John Smith".to_string()); + 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()), + ] + ); } #[test] diff --git a/tests/legacy/merge.rs b/tests/legacy/merge.rs index 989ae47..a489bdf 100644 --- a/tests/legacy/merge.rs +++ b/tests/legacy/merge.rs @@ -2,6 +2,8 @@ extern crate config; +use std::collections::HashMap; + use self::config::*; fn make() -> Config { @@ -21,11 +23,17 @@ fn test_merge() { assert_eq!(c.get("debug").ok(), Some(false)); assert_eq!(c.get("production").ok(), Some(true)); + assert_eq!(c.get("place.rating").ok(), Some(4.9)); + + let m: HashMap<String, String> = c.get("place.creator").unwrap(); assert_eq!( - c.get("place.creator.name").ok(), - Some("Somebody New".to_string()) + m.into_iter().collect::<Vec<(String, String)>>(), + vec![ + ("name".to_string(), "Somebody New".to_string()), + ("username".to_string(), "jsmith".to_string()), + ("email".to_string(), "jsmith@localhost".to_string()), + ] ); - assert_eq!(c.get("place.rating").ok(), Some(4.9)); } #[test] diff --git a/tests/merge.rs b/tests/merge.rs index 9de36b2..8d09417 100644 --- a/tests/merge.rs +++ b/tests/merge.rs @@ -2,6 +2,8 @@ extern crate config; +use std::collections::HashMap; + use config::*; fn make() -> Config { @@ -18,11 +20,17 @@ fn test_merge() { assert_eq!(c.get("debug").ok(), Some(false)); assert_eq!(c.get("production").ok(), Some(true)); + assert_eq!(c.get("place.rating").ok(), Some(4.9)); + + let m: HashMap<String, String> = c.get("place.creator").unwrap(); assert_eq!( - c.get("place.creator.name").ok(), - Some("Somebody New".to_string()) + m.into_iter().collect::<Vec<(String, String)>>(), + vec![ + ("name".to_string(), "Somebody New".to_string()), + ("username".to_string(), "jsmith".to_string()), + ("email".to_string(), "jsmith@localhost".to_string()), + ] ); - assert_eq!(c.get("place.rating").ok(), Some(4.9)); } #[test] |