summaryrefslogtreecommitdiffstats
path: root/tests
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
parent622efaca17256fb42dafc61c8df1f3037c1fb772 (diff)
Move order preservation under a feature gate
Diffstat (limited to 'tests')
-rw-r--r--tests/async_builder.rs5
-rw-r--r--tests/errors.rs5
-rw-r--r--tests/file_hjson.rs3
-rw-r--r--tests/file_json.rs32
-rw-r--r--tests/file_json5.rs32
-rw-r--r--tests/file_ron.rs32
-rw-r--r--tests/file_toml.rs32
-rw-r--r--tests/file_yaml.rs32
-rw-r--r--tests/get.rs36
-rw-r--r--tests/legacy/errors.rs3
-rw-r--r--tests/legacy/file_hjson.rs3
-rw-r--r--tests/legacy/file_json.rs32
-rw-r--r--tests/legacy/file_ron.rs32
-rw-r--r--tests/legacy/file_toml.rs32
-rw-r--r--tests/legacy/file_yaml.rs32
-rw-r--r--tests/legacy/get.rs36
-rw-r--r--tests/legacy/merge.rs26
-rw-r--r--tests/merge.rs26
18 files changed, 251 insertions, 180 deletions
diff --git a/tests/async_builder.rs b/tests/async_builder.rs
index a614d42..bf923d6 100644
--- a/tests/async_builder.rs
+++ b/tests/async_builder.rs
@@ -1,6 +1,7 @@
+#![cfg(feature = "preserve_order")]
+
use async_trait::async_trait;
use config::*;
-use linked_hash_map::LinkedHashMap;
use std::{env, fs, path, str::FromStr};
use tokio::{fs::File, io::AsyncReadExt};
@@ -19,7 +20,7 @@ impl AsyncFile {
#[async_trait]
impl AsyncSource for AsyncFile {
- async fn collect(&self) -> Result<LinkedHashMap<String, Value>, ConfigError> {
+ async fn collect(&self) -> Result<MapImpl<String, Value>, ConfigError> {
let mut path = env::current_dir().unwrap();
let local = path::PathBuf::from_str(&self.path).unwrap();
diff --git a/tests/errors.rs b/tests/errors.rs
index 703dddd..9004cbe 100644
--- a/tests/errors.rs
+++ b/tests/errors.rs
@@ -1,11 +1,10 @@
-#![cfg(feature = "toml")]
+#![cfg(all(feature = "toml", feature = "preserve_order"))]
extern crate config;
#[macro_use]
extern crate serde_derive;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
use config::*;
@@ -97,7 +96,7 @@ fn test_error_enum_de() {
]
.iter()
.cloned()
- .collect::<LinkedHashMap<String, Value>>()
+ .collect::<MapImpl<String, Value>>()
.into();
let confused_d = confused_v.try_into::<Diode>();
assert_eq!(
diff --git a/tests/file_hjson.rs b/tests/file_hjson.rs
index 376993f..4439d31 100644
--- a/tests/file_hjson.rs
+++ b/tests/file_hjson.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>,
}
diff --git a/tests/file_json.rs b/tests/file_json.rs
index c3ebe06..035403c 100644
--- a/tests/file_json.rs
+++ b/tests/file_json.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]
diff --git a/tests/file_json5.rs b/tests/file_json5.rs
index f92bce5..cb04718 100644
--- a/tests/file_json5.rs
+++ b/tests/file_json5.rs
@@ -9,7 +9,6 @@ extern crate serde_derive;
use config::*;
use float_cmp::ApproxEqUlps;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
#[derive(Debug, Deserialize)]
@@ -20,7 +19,7 @@ struct Place {
favorite: bool,
telephone: Option<String>,
reviews: u64,
- creator: LinkedHashMap<String, Value>,
+ creator: MapImpl<String, Value>,
rating: Option<f32>,
}
@@ -58,17 +57,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]
diff --git a/tests/file_ron.rs b/tests/file_ron.rs
index 71b9106..e1351b4 100644
--- a/tests/file_ron.rs
+++ b/tests/file_ron.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::*;
@@ -22,7 +21,7 @@ struct Place {
favorite: bool,
telephone: Option<String>,
reviews: u64,
- creator: LinkedHashMap<String, Value>,
+ creator: MapImpl<String, Value>,
rating: Option<f32>,
}
@@ -61,17 +60,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]
diff --git a/tests/file_toml.rs b/tests/file_toml.rs
index 77d4d31..c0bcb31 100644
--- a/tests/file_toml.rs
+++ b/tests/file_toml.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::*;
@@ -22,7 +21,7 @@ struct Place {
favorite: bool,
telephone: Option<String>,
reviews: u64,
- creator: LinkedHashMap<String, Value>,
+ creator: MapImpl<String, Value>,
rating: Option<f32>,
}
@@ -70,17 +69,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]
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]
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();
diff --git a/tests/legacy/errors.rs b/tests/legacy/errors.rs
index 070eb6d..4da586e 100644
--- a/tests/legacy/errors.rs
+++ b/tests/legacy/errors.rs
@@ -2,7 +2,6 @@
extern crate config;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
use self::config::*;
@@ -94,7 +93,7 @@ fn test_error_enum_de() {
]
.iter()
.cloned()
- .collect::<LinkedHashMap<String, Value>>()
+ .collect::<MapImpl<String, Value>>()
.into();
let confused_d = confused_v.try_into::<Diode>();
assert_eq!(
diff --git a/tests/legacy/file_hjson.rs b/tests/legacy/file_hjson.rs
index b846c91..8ca2d68 100644
--- a/tests/legacy/file_hjson.rs
+++ b/tests/legacy/file_hjson.rs
@@ -4,7 +4,6 @@ extern crate config;
extern crate float_cmp;
extern crate serde;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
use self::config::*;
@@ -18,7 +17,7 @@ struct Place {
favorite: bool,
telephone: Option<String>,
reviews: u64,
- creator: LinkedHashMap<String, Value>,
+ creator: MapImpl<String, Value>,
rating: Option<f32>,
}
diff --git a/tests/legacy/file_json.rs b/tests/legacy/file_json.rs
index 6a9b577..2486a55 100644
--- a/tests/legacy/file_json.rs
+++ b/tests/legacy/file_json.rs
@@ -4,7 +4,6 @@ extern crate config;
extern crate float_cmp;
extern crate serde;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
use self::config::*;
@@ -18,7 +17,7 @@ struct Place {
favorite: bool,
telephone: Option<String>,
reviews: u64,
- creator: LinkedHashMap<String, Value>,
+ creator: MapImpl<String, Value>,
rating: Option<f32>,
}
@@ -57,17 +56,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]
diff --git a/tests/legacy/file_ron.rs b/tests/legacy/file_ron.rs
index bfd31af..19b629d 100644
--- a/tests/legacy/file_ron.rs
+++ b/tests/legacy/file_ron.rs
@@ -4,7 +4,6 @@ extern crate config;
extern crate float_cmp;
extern crate serde;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
use self::config::*;
@@ -19,7 +18,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]
diff --git a/tests/legacy/file_toml.rs b/tests/legacy/file_toml.rs
index 24c590e..53310b4 100644
--- a/tests/legacy/file_toml.rs
+++ b/tests/legacy/file_toml.rs
@@ -4,7 +4,6 @@ extern crate config;
extern crate float_cmp;
extern crate serde;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
use self::config::*;
@@ -19,7 +18,7 @@ struct Place {
favorite: bool,
telephone: Option<String>,
reviews: u64,
- creator: LinkedHashMap<String, Value>,
+ creator: MapImpl<String, Value>,
rating: Option<f32>,
}
@@ -68,17 +67,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]
diff --git a/tests/legacy/file_yaml.rs b/tests/legacy/file_yaml.rs
index af04ef6..572e10c 100644
--- a/tests/legacy/file_yaml.rs
+++ b/tests/legacy/file_yaml.rs
@@ -4,7 +4,6 @@ extern crate config;
extern crate float_cmp;
extern crate serde;
-use linked_hash_map::LinkedHashMap;
use std::path::PathBuf;
use self::config::*;
@@ -18,7 +17,7 @@ struct Place {
favorite: bool,
telephone: Option<String>,
reviews: u64,
- creator: LinkedHashMap<String, Value>,
+ creator: MapImpl<String, Value>,
rating: Option<f32>,
}
@@ -57,17 +56,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]
diff --git a/tests/legacy/get.rs b/tests/legacy/get.rs
index c246567..6b12a57 100644
--- a/tests/legacy/get.rs
+++ b/tests/legacy/get.rs
@@ -4,7 +4,6 @@ extern crate config;
extern crate float_cmp;
extern crate serde;
-use linked_hash_map::LinkedHashMap;
use std::collections::HashSet;
use self::config::*;
@@ -106,7 +105,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!(
@@ -119,23 +118,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();
@@ -220,7 +224,7 @@ fn test_enum() {
}
#[derive(Debug, Deserialize)]
struct Settings {
- diodes: LinkedHashMap<String, Diode>,
+ diodes: MapImpl<String, Diode>,
}
let c = make();
@@ -253,7 +257,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>,
}
@@ -269,7 +273,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();
diff --git a/tests/legacy/merge.rs b/tests/legacy/merge.rs
index 75cb16d..d93724d 100644
--- a/tests/legacy/merge.rs
+++ b/tests/legacy/merge.rs
@@ -3,7 +3,6 @@
extern crate config;
use self::config::*;
-use linked_hash_map::LinkedHashMap;
fn make() -> Config {
let mut c = Config::default();
@@ -24,15 +23,22 @@ fn test_merge() {
assert_eq!(c.get("production").ok(), Some(true));
assert_eq!(c.get("place.rating").ok(), Some(4.9));
- let m: LinkedHashMap<String, String> = c.get("place.creator").unwrap();
- assert_eq!(
- 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()),
- ]
- );
+ if cfg!(feature = "preserve_order") {
+ let m: MapImpl<String, String> = c.get("place.creator").unwrap();
+ assert_eq!(
+ 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()),
+ ]
+ );
+ } else {
+ assert_eq!(
+ c.get("place.creator.name").ok(),
+ Some("Somebody New".to_string())
+ );
+ }
}
#[test]
diff --git a/tests/merge.rs b/tests/merge.rs
index 922ae31..93e2f39 100644
--- a/tests/merge.rs
+++ b/tests/merge.rs
@@ -3,7 +3,6 @@
extern crate config;
use config::*;
-use linked_hash_map::LinkedHashMap;
fn make() -> Config {
Config::builder()
@@ -21,15 +20,22 @@ fn test_merge() {
assert_eq!(c.get("production").ok(), Some(true));
assert_eq!(c.get("place.rating").ok(), Some(4.9));
- let m: LinkedHashMap<String, String> = c.get("place.creator").unwrap();
- assert_eq!(
- 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()),
- ]
- );
+ if cfg!(feature = "preserve_order") {
+ let m: MapImpl<String, String> = c.get("place.creator").unwrap();
+ assert_eq!(
+ 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()),
+ ]
+ );
+ } else {
+ assert_eq!(
+ c.get("place.creator.name").ok(),
+ Some("Somebody New".to_string())
+ );
+ }
}
#[test]