File: test_json_ptr_walk.sh

package info (click to toggle)
lnav 0.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,536 kB
  • ctags: 4,798
  • sloc: cpp: 37,738; sh: 6,871; ansic: 5,090; makefile: 670; python: 196; sql: 67
file content (67 lines) | stat: -rw-r--r-- 886 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/bash

run_test ./drive_json_ptr_walk <<EOF
{ "foo" : 1 }
EOF

check_output "simple object" <<EOF
/foo = 1
EOF

run_test ./drive_json_ptr_walk <<EOF
{ "~tstack/julia" : 1 }
EOF

check_output "escaped object" <<EOF
/~0tstack~1julia = 1
EOF

run_test ./drive_json_ptr_walk <<EOF
1
EOF

check_output "root value" <<EOF
 = 1
EOF

run_test ./drive_json_ptr_walk <<EOF
[1, 2, 3]
EOF

check_output "array" <<EOF
/0 = 1
/1 = 2
/2 = 3
EOF

run_test ./drive_json_ptr_walk <<EOF
[1, 2, 3, [4, 5, 6]]
EOF

check_output "nested array" <<EOF
/0 = 1
/1 = 2
/2 = 3
/3/0 = 4
/3/1 = 5
/3/2 = 6
EOF

run_test ./drive_json_ptr_walk <<EOF
[null, true, 123.0, "foo", { "bar" : { "baz" : [1, 2, 3]} }, ["a", null]]
EOF

check_error_output "" <<EOF
EOF

check_output "complex" <<EOF
/0 = null
/1 = true
/2 = 123.0
/3 = "foo"
/4/bar/baz/0 = 1
/4/bar/baz/1 = 2
/4/bar/baz/2 = 3
/5/0 = "a"
/5/1 = null
EOF