summaryrefslogtreecommitdiffstats
path: root/tests/get.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/get.rs
parent1716c2fe7571b03215a5ae09c91f508d03335c2a (diff)
Support subscript access on path get/set
Diffstat (limited to 'tests/get.rs')
-rw-r--r--tests/get.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/get.rs b/tests/get.rs
index 2df50a5..1922fca 100644
--- a/tests/get.rs
+++ b/tests/get.rs
@@ -88,6 +88,17 @@ fn test_get_scalar_path() {
}
#[test]
+fn test_get_scalar_path_subscript() {
+ let c = make();
+
+ assert_eq!(c.get("arr[2]").ok(), Some(3));
+ assert_eq!(c.get("items[0].name").ok(), Some("1".to_string()));
+ assert_eq!(c.get("items[1].name").ok(), Some("2".to_string()));
+ assert_eq!(c.get("items[-1].name").ok(), Some("2".to_string()));
+ assert_eq!(c.get("items[-2].name").ok(), Some("1".to_string()));
+}
+
+#[test]
fn test_map() {
let c = make();
let m: HashMap<String, Value> = c.get("place").unwrap();