summaryrefslogtreecommitdiffstats
path: root/tests/set.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/set.rs')
-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();