diff options
author | Ryan Leckey <ryan@launchbadge.com> | 2017-06-03 01:22:38 -0700 |
---|---|---|
committer | Ryan Leckey <ryan@launchbadge.com> | 2017-06-03 01:22:38 -0700 |
commit | 43c141f87a0167e50802f097cf04896258acb5e6 (patch) | |
tree | 799cc797eecf5e699322fbb55debdf75f576a7c0 /tests/get_array.rs | |
parent | 0a478cf075cc93ede4f631a5be4502e2da2f0cf7 (diff) |
Add many more tests
Diffstat (limited to 'tests/get_array.rs')
-rw-r--r-- | tests/get_array.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/get_array.rs b/tests/get_array.rs new file mode 100644 index 0000000..579597c --- /dev/null +++ b/tests/get_array.rs @@ -0,0 +1,39 @@ +extern crate config; +extern crate serde; + +#[macro_use] +extern crate serde_derive; + +use config::*; + +#[derive(Debug, Deserialize)] +struct Settings { + #[serde(rename = "arr")] + elements: Vec<String>, +} + +fn make() -> Config { + let mut c = Config::default(); + c.merge(File::new("tests/Settings", FileFormat::Toml)) + .unwrap(); + + c +} + +#[test] +fn test_array_scalar() { + let c = make(); + let arr: Vec<i64> = c.get("arr").unwrap(); + + assert_eq!(arr.len(), 10); + assert_eq!(arr[3], 4); +} + +#[test] +fn test_struct_array() { + let c = make(); + let s: Settings = c.deserialize().unwrap(); + + assert_eq!(s.elements.len(), 10); + assert_eq!(s.elements[3], "4".to_string()); +} |