summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorXX <freecoder.xx@gmail.com>2018-04-08 16:25:56 +0300
committerXX <freecoder.xx@gmail.com>2018-04-08 16:37:21 +0300
commit4ac0078cdbea3fdb395c62077290e6368f13533d (patch)
tree2807e5826f834780e03cb1a7c4810961b293813e /tests
parente8fa9fee96185ddd18ebcef8a925c75459111edb (diff)
Fix initialy set arr path
Diffstat (limited to 'tests')
-rw-r--r--tests/set.rs16
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();