summaryrefslogtreecommitdiffstats
path: root/src/tools/jsondoclint/src/json_find/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/jsondoclint/src/json_find/tests.rs')
-rw-r--r--src/tools/jsondoclint/src/json_find/tests.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/jsondoclint/src/json_find/tests.rs b/src/tools/jsondoclint/src/json_find/tests.rs
new file mode 100644
index 000000000..2a5335307
--- /dev/null
+++ b/src/tools/jsondoclint/src/json_find/tests.rs
@@ -0,0 +1,27 @@
+use super::*;
+
+#[test]
+fn basic_find() {
+ use SelectorPart::*;
+
+ let j = serde_json::json!({
+ "index": {
+ "4": {
+ "inner": {
+ "items": ["1", "2", "3"]
+ }
+ }
+ }
+ });
+
+ let sel = find_selector(&j, &serde_json::json!("1"));
+ let exp: Vec<Vec<SelectorPart>> = vec![vec![
+ Field("index".to_owned()),
+ Field("4".to_owned()),
+ Field("inner".to_owned()),
+ Field("items".to_owned()),
+ Index(0),
+ ]];
+
+ assert_eq!(exp, sel);
+}