summaryrefslogtreecommitdiffstats
path: root/src/yajlpp/test_json_op.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 17:44:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 17:44:55 +0000
commit5068d34c08f951a7ea6257d305a1627b09a95817 (patch)
tree08213e2be853396a3b07ce15dbe222644dcd9a89 /src/yajlpp/test_json_op.sh
parentInitial commit. (diff)
downloadlnav-upstream.tar.xz
lnav-upstream.zip
Adding upstream version 0.11.1.upstream/0.11.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xsrc/yajlpp/test_json_op.sh114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/yajlpp/test_json_op.sh b/src/yajlpp/test_json_op.sh
new file mode 100755
index 0000000..91a3849
--- /dev/null
+++ b/src/yajlpp/test_json_op.sh
@@ -0,0 +1,114 @@
+#! /bin/bash
+
+run_test ./drive_json_op get "" <<EOF
+3
+EOF
+
+check_output "cannot read root number value" <<EOF
+3
+EOF
+
+run_test ./drive_json_op get "" <<EOF
+null
+EOF
+
+check_output "cannot read root null value" <<EOF
+null
+EOF
+
+run_test ./drive_json_op get "" <<EOF
+true
+EOF
+
+check_output "cannot read root bool value" <<EOF
+true
+EOF
+
+run_test ./drive_json_op get "" <<EOF
+"str"
+EOF
+
+check_output "cannot read root string value" <<EOF
+"str"
+EOF
+
+run_test ./drive_json_op get "" <<EOF
+{ "val" : 3, "other" : 2 }
+EOF
+
+check_output "cannot read root map value" <<EOF
+{
+ "val": 3,
+ "other": 2
+}
+EOF
+
+run_test ./drive_json_op get /val <<EOF
+{ "val" : 3 }
+EOF
+
+check_output "cannot read top-level value" <<EOF
+3
+EOF
+
+run_test ./drive_json_op get /val <<EOF
+{ "other" : { "val" : 5 }, "val" : 3 }
+EOF
+
+check_output "read wrong value" <<EOF
+3
+EOF
+
+run_test ./drive_json_op get /other <<EOF
+{ "other" : { "val" : 5 }, "val" : 3 }
+EOF
+
+check_output "cannot read map" <<EOF
+{
+ "val": 5
+}
+EOF
+
+run_test ./drive_json_op get /other/val <<EOF
+{ "other" : { "val" : 5 }, "val" : 3 }
+EOF
+
+check_output "cannot read nested map" <<EOF
+5
+EOF
+
+
+run_test ./drive_json_op get "" <<EOF
+[0, 1]
+EOF
+
+check_output "cannot read root array value" <<EOF
+[
+ 0,
+ 1
+]
+EOF
+
+run_test ./drive_json_op get "/6" <<EOF
+[null, true, 1, "str", {"sub":[10, 11]}, [21, [33, 34], 66], 2]
+EOF
+
+check_output "cannot read array value" <<EOF
+2
+EOF
+
+run_test ./drive_json_op get "/ID" <<EOF
+{"ID":"P1","ProcessID":"P1","Name":"VxWorks","CanSuspend":true,"CanResume":1,"IsContainer":true,"WordSize":4,"CanTerminate":true,"CanDetach":true,"RCGroup":"P1","SymbolsGroup":"P1","CPUGroup":"P1","DiagnosticTestProcess":true}
+EOF
+
+check_output "cannot read key value" <<EOF
+"P1"
+EOF
+
+run_test ./drive_json_op get "/arr/1/id" <<EOF
+{"arr": [{"id": 1}, {"id": 2}]}
+EOF
+
+check_output "cannot read key value" <<EOF
+2
+EOF