summaryrefslogtreecommitdiffstats
path: root/tests/set.rs
diff options
context:
space:
mode:
authorRyan Leckey <ryan@launchbadge.com>2017-06-16 11:15:40 -0700
committerRyan Leckey <ryan@launchbadge.com>2017-06-16 11:15:40 -0700
commit05e9cd421e75173462072e57ab7e27881730d250 (patch)
tree8db6e8d6951c57a3d50093a8fd789c2941df849f /tests/set.rs
parent1716c2fe7571b03215a5ae09c91f508d03335c2a (diff)
Support subscript access on path get/set
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 e02814b..14ddfae 100644
--- a/tests/set.rs
+++ b/tests/set.rs
@@ -40,6 +40,22 @@ fn test_set_scalar_path() {
}
#[test]
+fn test_set_arr_path() {
+ let mut c = Config::default();
+
+ c.merge(File::new("tests/Settings", FileFormat::Toml))
+ .unwrap();
+
+ c.set("items[0].name", "John").unwrap();
+
+ assert_eq!(c.get("items[0].name").ok(), Some("John".to_string()));
+
+ c.set("items[2]", "George").unwrap();
+
+ assert_eq!(c.get("items[2]").ok(), Some("George".to_string()));
+}
+
+#[test]
fn test_set_capital() {
let mut c = Config::default();