tests: blobmsg/json: add more test cases
[project/libubox.git] / tests / cram / test_blobmsg.t
1 check that blobmsg is producing expected results:
2
3 $ [ -n "$TEST_BIN_DIR" ] && export PATH="$TEST_BIN_DIR:$PATH"
4
5 $ valgrind --quiet --leak-check=full test-blobmsg
6 [*] blobmsg dump:
7 Message: Hello, world!
8 List: {
9 0 (i8)
10 100 (i8)
11 -128 (i8)
12 127 (i8)
13 -32768 (i16)
14 32767 (i16)
15 -2147483648 (i32)
16 2147483647 (i32)
17 -9223372036854775808 (i64)
18 9223372036854775807 (i64)
19 133.700000 (dbl)
20 }
21 Testdata: {
22 \tdouble : 133.700000 (dbl) (esc)
23 \tfoo : 0 (i8) (esc)
24 \tpoo : 100 (i8) (esc)
25 \tmoo-min : -128 (i8) (esc)
26 \tmoo-max : 127 (i8) (esc)
27 \tbar-min : -32768 (i16) (esc)
28 \tbar-max : 32767 (i16) (esc)
29 \tbaz-min : -2147483648 (i32) (esc)
30 \tbaz-max : 2147483647 (i32) (esc)
31 \ttaz-min : -9223372036854775808 (i64) (esc)
32 \ttaz-max : 9223372036854775807 (i64) (esc)
33 \tworld : 2 (str) (esc)
34 }
35
36 [*] blobmsg to json: {"message":"Hello, world!","testdata":{"double":133.700000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,133.700000]}
37
38 [*] blobmsg from json:
39 Message: Hello, world!
40 List: {
41 0 (i8)
42 1 (i8)
43 1 (i8)
44 1 (i8)
45 32768 (i32)
46 32767 (i32)
47 -2147483648 (i32)
48 2147483647 (i32)
49 -2147483648 (i32)
50 2147483647 (i32)
51 133.700000 (dbl)
52 }
53 Testdata: {
54 \tdouble : 133.700000 (dbl) (esc)
55 \tfoo : 0 (i8) (esc)
56 \tpoo : 1 (i8) (esc)
57 \tmoo-min : 1 (i8) (esc)
58 \tmoo-max : 1 (i8) (esc)
59 \tbar-min : 32768 (i32) (esc)
60 \tbar-max : 32767 (i32) (esc)
61 \tbaz-min : -2147483648 (i32) (esc)
62 \tbaz-max : 2147483647 (i32) (esc)
63 \ttaz-min : -2147483648 (i32) (esc)
64 \ttaz-max : 2147483647 (i32) (esc)
65 \tworld : 2 (str) (esc)
66 }
67
68 $ test-blobmsg-san
69 [*] blobmsg dump:
70 Message: Hello, world!
71 List: {
72 0 (i8)
73 100 (i8)
74 -128 (i8)
75 127 (i8)
76 -32768 (i16)
77 32767 (i16)
78 -2147483648 (i32)
79 2147483647 (i32)
80 -9223372036854775808 (i64)
81 9223372036854775807 (i64)
82 133.700000 (dbl)
83 }
84 Testdata: {
85 \tdouble : 133.700000 (dbl) (esc)
86 \tfoo : 0 (i8) (esc)
87 \tpoo : 100 (i8) (esc)
88 \tmoo-min : -128 (i8) (esc)
89 \tmoo-max : 127 (i8) (esc)
90 \tbar-min : -32768 (i16) (esc)
91 \tbar-max : 32767 (i16) (esc)
92 \tbaz-min : -2147483648 (i32) (esc)
93 \tbaz-max : 2147483647 (i32) (esc)
94 \ttaz-min : -9223372036854775808 (i64) (esc)
95 \ttaz-max : 9223372036854775807 (i64) (esc)
96 \tworld : 2 (str) (esc)
97 }
98
99 [*] blobmsg to json: {"message":"Hello, world!","testdata":{"double":133.700000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,133.700000]}
100
101 [*] blobmsg from json:
102 Message: Hello, world!
103 List: {
104 0 (i8)
105 1 (i8)
106 1 (i8)
107 1 (i8)
108 32768 (i32)
109 32767 (i32)
110 -2147483648 (i32)
111 2147483647 (i32)
112 -2147483648 (i32)
113 2147483647 (i32)
114 133.700000 (dbl)
115 }
116 Testdata: {
117 \tdouble : 133.700000 (dbl) (esc)
118 \tfoo : 0 (i8) (esc)
119 \tpoo : 1 (i8) (esc)
120 \tmoo-min : 1 (i8) (esc)
121 \tmoo-max : 1 (i8) (esc)
122 \tbar-min : 32768 (i32) (esc)
123 \tbar-max : 32767 (i32) (esc)
124 \tbaz-min : -2147483648 (i32) (esc)
125 \tbaz-max : 2147483647 (i32) (esc)
126 \ttaz-min : -2147483648 (i32) (esc)
127 \ttaz-max : 2147483647 (i32) (esc)
128 \tworld : 2 (str) (esc)
129 }
130
131 $ test-blobmsg-san
132 [*] blobmsg dump:
133 Message: Hello, world!
134 List: {
135 0 (i8)
136 100 (i8)
137 -128 (i8)
138 127 (i8)
139 -32768 (i16)
140 32767 (i16)
141 -2147483648 (i32)
142 2147483647 (i32)
143 -9223372036854775808 (i64)
144 9223372036854775807 (i64)
145 133.700000 (dbl)
146 }
147 Testdata: {
148 \tdouble : 133.700000 (dbl) (esc)
149 \tfoo : 0 (i8) (esc)
150 \tpoo : 100 (i8) (esc)
151 \tmoo-min : -128 (i8) (esc)
152 \tmoo-max : 127 (i8) (esc)
153 \tbar-min : -32768 (i16) (esc)
154 \tbar-max : 32767 (i16) (esc)
155 \tbaz-min : -2147483648 (i32) (esc)
156 \tbaz-max : 2147483647 (i32) (esc)
157 \ttaz-min : -9223372036854775808 (i64) (esc)
158 \ttaz-max : 9223372036854775807 (i64) (esc)
159 \tworld : 2 (str) (esc)
160 }
161
162 [*] blobmsg to json: {"message":"Hello, world!","testdata":{"double":133.700000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,133.700000]}
163
164 [*] blobmsg from json:
165 Message: Hello, world!
166 List: {
167 0 (i8)
168 1 (i8)
169 1 (i8)
170 1 (i8)
171 32768 (i32)
172 32767 (i32)
173 -2147483648 (i32)
174 2147483647 (i32)
175 -2147483648 (i32)
176 2147483647 (i32)
177 133.700000 (dbl)
178 }
179 Testdata: {
180 \tdouble : 133.700000 (dbl) (esc)
181 \tfoo : 0 (i8) (esc)
182 \tpoo : 1 (i8) (esc)
183 \tmoo-min : 1 (i8) (esc)
184 \tmoo-max : 1 (i8) (esc)
185 \tbar-min : 32768 (i32) (esc)
186 \tbar-max : 32767 (i32) (esc)
187 \tbaz-min : -2147483648 (i32) (esc)
188 \tbaz-max : 2147483647 (i32) (esc)
189 \ttaz-min : -2147483648 (i32) (esc)
190 \ttaz-max : 2147483647 (i32) (esc)
191 \tworld : 2 (str) (esc)
192 }
193
194 $ test-blobmsg-san
195 [*] blobmsg dump:
196 Message: Hello, world!
197 List: {
198 0 (i8)
199 100 (i8)
200 -128 (i8)
201 127 (i8)
202 -32768 (i16)
203 32767 (i16)
204 -2147483648 (i32)
205 2147483647 (i32)
206 -9223372036854775808 (i64)
207 9223372036854775807 (i64)
208 133.700000 (dbl)
209 }
210 Testdata: {
211 \tdouble : 133.700000 (dbl) (esc)
212 \tfoo : 0 (i8) (esc)
213 \tpoo : 100 (i8) (esc)
214 \tmoo-min : -128 (i8) (esc)
215 \tmoo-max : 127 (i8) (esc)
216 \tbar-min : -32768 (i16) (esc)
217 \tbar-max : 32767 (i16) (esc)
218 \tbaz-min : -2147483648 (i32) (esc)
219 \tbaz-max : 2147483647 (i32) (esc)
220 \ttaz-min : -9223372036854775808 (i64) (esc)
221 \ttaz-max : 9223372036854775807 (i64) (esc)
222 \tworld : 2 (str) (esc)
223 }
224
225 [*] blobmsg to json: {"message":"Hello, world!","testdata":{"double":133.700000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,133.700000]}
226
227 [*] blobmsg from json:
228 Message: Hello, world!
229 List: {
230 0 (i8)
231 1 (i8)
232 1 (i8)
233 1 (i8)
234 32768 (i32)
235 32767 (i32)
236 -2147483648 (i32)
237 2147483647 (i32)
238 -2147483648 (i32)
239 2147483647 (i32)
240 133.700000 (dbl)
241 }
242 Testdata: {
243 \tdouble : 133.700000 (dbl) (esc)
244 \tfoo : 0 (i8) (esc)
245 \tpoo : 1 (i8) (esc)
246 \tmoo-min : 1 (i8) (esc)
247 \tmoo-max : 1 (i8) (esc)
248 \tbar-min : 32768 (i32) (esc)
249 \tbar-max : 32767 (i32) (esc)
250 \tbaz-min : -2147483648 (i32) (esc)
251 \tbaz-max : 2147483647 (i32) (esc)
252 \ttaz-min : -2147483648 (i32) (esc)
253 \ttaz-max : 2147483647 (i32) (esc)
254 \tworld : 2 (str) (esc)
255 }