From 4ac0078cdbea3fdb395c62077290e6368f13533d Mon Sep 17 00:00:00 2001 From: XX Date: Sun, 8 Apr 2018 16:25:56 +0300 Subject: Fix initialy set arr path --- tests/set.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') 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(); -- cgit v1.2.3