@@ -14,6 +14,7 @@ struct test_nested {
14
14
bool nested_bool ;
15
15
const char * nested_string ;
16
16
int64_t nested_int64 ;
17
+ uint64_t nested_uint64 ;
17
18
};
18
19
19
20
struct test_struct {
@@ -22,6 +23,8 @@ struct test_struct {
22
23
bool some_bool ;
23
24
int64_t some_int64 ;
24
25
int64_t another_int64 ;
26
+ int64_t some_uint64 ;
27
+ int64_t another_uint64 ;
25
28
struct test_nested some_nested_struct ;
26
29
int some_array [16 ];
27
30
size_t some_array_len ;
@@ -51,6 +54,9 @@ struct test_int_limits {
51
54
int64_t int64_max ;
52
55
int64_t int64_cero ;
53
56
int64_t int64_min ;
57
+ uint64_t uint64_max ;
58
+ uint64_t uint64_cero ;
59
+ uint64_t uint64_min ;
54
60
};
55
61
56
62
static const struct json_obj_descr nested_descr [] = {
@@ -60,6 +66,8 @@ static const struct json_obj_descr nested_descr[] = {
60
66
JSON_TOK_STRING ),
61
67
JSON_OBJ_DESCR_PRIM (struct test_nested , nested_int64 ,
62
68
JSON_TOK_INT64 ),
69
+ JSON_OBJ_DESCR_PRIM (struct test_nested , nested_uint64 ,
70
+ JSON_TOK_UINT64 ),
63
71
};
64
72
65
73
static const struct json_obj_descr test_descr [] = {
@@ -70,6 +78,10 @@ static const struct json_obj_descr test_descr[] = {
70
78
JSON_TOK_INT64 ),
71
79
JSON_OBJ_DESCR_PRIM (struct test_struct , another_int64 ,
72
80
JSON_TOK_INT64 ),
81
+ JSON_OBJ_DESCR_PRIM (struct test_struct , some_uint64 ,
82
+ JSON_TOK_UINT64 ),
83
+ JSON_OBJ_DESCR_PRIM (struct test_struct , another_uint64 ,
84
+ JSON_TOK_UINT64 ),
73
85
JSON_OBJ_DESCR_OBJECT (struct test_struct , some_nested_struct ,
74
86
nested_descr ),
75
87
JSON_OBJ_DESCR_ARRAY (struct test_struct , some_array ,
@@ -104,6 +116,9 @@ static const struct json_obj_descr obj_limits_descr[] = {
104
116
JSON_OBJ_DESCR_PRIM (struct test_int_limits , int64_max , JSON_TOK_INT64 ),
105
117
JSON_OBJ_DESCR_PRIM (struct test_int_limits , int64_cero , JSON_TOK_INT64 ),
106
118
JSON_OBJ_DESCR_PRIM (struct test_int_limits , int64_min , JSON_TOK_INT64 ),
119
+ JSON_OBJ_DESCR_PRIM (struct test_int_limits , uint64_max , JSON_TOK_UINT64 ),
120
+ JSON_OBJ_DESCR_PRIM (struct test_int_limits , uint64_cero , JSON_TOK_UINT64 ),
121
+ JSON_OBJ_DESCR_PRIM (struct test_int_limits , uint64_min , JSON_TOK_UINT64 ),
107
122
};
108
123
109
124
struct array {
@@ -197,12 +212,15 @@ ZTEST(lib_json_test, test_json_encoding)
197
212
.some_int = 42 ,
198
213
.some_int64 = 1152921504606846977 ,
199
214
.another_int64 = -2305843009213693937 ,
215
+ .some_uint64 = 18446744073709551615U ,
216
+ .another_uint64 = 0 ,
200
217
.some_bool = true,
201
218
.some_nested_struct = {
202
219
.nested_int = -1234 ,
203
220
.nested_bool = false,
204
221
.nested_string = "this should be escaped: \t" ,
205
222
.nested_int64 = 4503599627370496 ,
223
+ .nested_uint64 = 18446744073709551610U ,
206
224
},
207
225
.some_array [0 ] = 1 ,
208
226
.some_array [1 ] = 4 ,
@@ -222,6 +240,7 @@ ZTEST(lib_json_test, test_json_encoding)
222
240
.nested_bool = true,
223
241
.nested_string = "no escape necessary" ,
224
242
.nested_int64 = 4503599627370496 ,
243
+ .nested_uint64 = 18446744073709551610U ,
225
244
},
226
245
.nested_obj_array = {
227
246
{1 , true, "true" },
@@ -233,21 +252,25 @@ ZTEST(lib_json_test, test_json_encoding)
233
252
"\"some_int\":42,\"some_bool\":true,"
234
253
"\"some_int64\":1152921504606846977,"
235
254
"\"another_int64\":-2305843009213693937,"
255
+ "\"some_uint64\":18446744073709551615,"
256
+ "\"another_uint64\":0,"
236
257
"\"some_nested_struct\":{\"nested_int\":-1234,"
237
258
"\"nested_bool\":false,\"nested_string\":"
238
259
"\"this should be escaped: \\t\","
239
- "\"nested_int64\":4503599627370496},"
260
+ "\"nested_int64\":4503599627370496,"
261
+ "\"nested_uint64\":18446744073709551610},"
240
262
"\"some_array\":[1,4,8,16,32],"
241
263
"\"another_b!@l\":true,"
242
264
"\"if\":false,"
243
265
"\"another-array\":[2,3,5,7],"
244
266
"\"4nother_ne$+\":{\"nested_int\":1234,"
245
267
"\"nested_bool\":true,"
246
268
"\"nested_string\":\"no escape necessary\","
247
- "\"nested_int64\":4503599627370496},"
269
+ "\"nested_int64\":4503599627370496,"
270
+ "\"nested_uint64\":18446744073709551610},"
248
271
"\"nested_obj_array\":["
249
- "{\"nested_int\":1,\"nested_bool\":true,\"nested_string\":\"true\",\"nested_int64\":0},"
250
- "{\"nested_int\":0,\"nested_bool\":false,\"nested_string\":\"false\",\"nested_int64\":0}]"
272
+ "{\"nested_int\":1,\"nested_bool\":true,\"nested_string\":\"true\",\"nested_int64\":0,\"nested_uint64\":0 },"
273
+ "{\"nested_int\":0,\"nested_bool\":false,\"nested_string\":\"false\",\"nested_int64\":0,\"nested_uint64\":0 }]"
251
274
"}" ;
252
275
char buffer [sizeof (encoded )];
253
276
int ret ;
@@ -274,6 +297,8 @@ ZTEST(lib_json_test, test_json_decoding)
274
297
"\r ,"
275
298
"\"some_int64\":-4611686018427387904,"
276
299
"\"another_int64\":-2147483648,"
300
+ "\"some_uint64\":18446744073709551615,"
301
+ "\"another_uint64\":0,"
277
302
"\"some_nested_struct\":{ "
278
303
"\"nested_int\":-1234,\n\n"
279
304
"\"nested_bool\":false,\t"
@@ -368,7 +393,10 @@ ZTEST(lib_json_test, test_json_limits)
368
393
"\"int_min\":-2147483648,"
369
394
"\"int64_max\":9223372036854775807,"
370
395
"\"int64_cero\":0,"
371
- "\"int64_min\":-9223372036854775808"
396
+ "\"int64_min\":-9223372036854775808,"
397
+ "\"uint64_max\":18446744073709551615,"
398
+ "\"uint64_cero\":0,"
399
+ "\"uint64_min\":0"
372
400
"}" ;
373
401
374
402
struct test_int_limits limits = {
@@ -378,6 +406,9 @@ ZTEST(lib_json_test, test_json_limits)
378
406
.int64_max = INT64_MAX ,
379
407
.int64_cero = 0 ,
380
408
.int64_min = INT64_MIN ,
409
+ .uint64_max = UINT64_MAX ,
410
+ .uint64_cero = 0 ,
411
+ .uint64_min = 0 ,
381
412
};
382
413
383
414
char buffer [sizeof (encoded )];
0 commit comments