diff options
author | Ryan Leckey <leckey.ryan@gmail.com> | 2018-07-02 15:06:21 -0700 |
---|---|---|
committer | Ryan Leckey <leckey.ryan@gmail.com> | 2018-07-02 15:06:21 -0700 |
commit | b8a1d8a65defb08c501df83b464a55f270765876 (patch) | |
tree | 3668b5983885018401d48e2b4d233ab678f71f8a /tests/set.rs | |
parent | e5a8323544ec98254d459ec6ecac43c162529390 (diff) | |
parent | 6c856712825f69993f285c951cc32edb3858b61a (diff) |
Merge branch 'master' of https://github.com/limbo-rs/config-rs
Diffstat (limited to 'tests/set.rs')
-rw-r--r-- | tests/set.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/set.rs b/tests/set.rs index 0b0f1a3..577e074 100644 --- a/tests/set.rs +++ b/tests/set.rs @@ -29,6 +29,10 @@ fn test_set_scalar_default() { fn test_set_scalar_path() { let mut c = Config::default(); + c.set("first.second.third", true).unwrap(); + + assert_eq!(c.get("first.second.third").ok(), Some(true)); + c.merge(File::new("tests/Settings", FileFormat::Toml)) .unwrap(); @@ -43,6 +47,18 @@ fn test_set_scalar_path() { fn test_set_arr_path() { let mut c = Config::default(); + c.set("items[0].name", "Ivan").unwrap(); + + assert_eq!(c.get("items[0].name").ok(), Some("Ivan".to_string())); + + c.set("data[0].things[1].name", "foo").unwrap(); + c.set("data[0].things[1].value", 42).unwrap(); + c.set("data[1]", 0).unwrap(); + + assert_eq!(c.get("data[0].things[1].name").ok(), Some("foo".to_string())); + assert_eq!(c.get("data[0].things[1].value").ok(), Some(42)); + assert_eq!(c.get("data[1]").ok(), Some(0)); + c.merge(File::new("tests/Settings", FileFormat::Toml)) .unwrap(); |