Skip to content

Commit 2304331

Browse files
mrfuchscarlescufi
authored andcommitted
tests: lib: json: Switch non-ascii text to octal escape sequences
Switch the non-ascii text in the tests to use octal escape sequences to avoid potential compiler issues on platforms not defaulting to utf-8 text encodings. Signed-off-by: Markus Fuchs <[email protected]>
1 parent ae6aa61 commit 2304331

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

tests/lib/json/src/main.c

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ ZTEST(lib_json_test, test_json_decoding_array_array)
260260
int ret;
261261
struct obj_array_array obj_array_array_ts;
262262
char encoded[] = "{\"objects_array\":["
263-
"[{\"height\":168,\"name\":\"Simón Bolívar\"}],"
264-
"[{\"height\":173,\"name\":\"Pelé\"}],"
263+
"[{\"height\":168,\"name\":\"Sim\303\263n Bol\303\255var\"}],"
264+
"[{\"height\":173,\"name\":\"Pel\303\251\"}],"
265265
"[{\"height\":195,\"name\":\"Usain Bolt\"}]]"
266266
"}";
267267

@@ -275,14 +275,14 @@ ZTEST(lib_json_test, test_json_decoding_array_array)
275275
"Array doesn't have correct number of items");
276276

277277
zassert_true(!strcmp(obj_array_array_ts.objects_array[0].objects.name,
278-
"Simón Bolívar"), "String not decoded correctly");
278+
"Sim\303\263n Bol\303\255var"), "String not decoded correctly");
279279
zassert_equal(obj_array_array_ts.objects_array[0].objects.height, 168,
280-
"Simón Bolívar height not decoded correctly");
280+
"Sim\303\263n Bol\303\255var height not decoded correctly");
281281

282282
zassert_true(!strcmp(obj_array_array_ts.objects_array[1].objects.name,
283-
"Pelé"), "String not decoded correctly");
283+
"Pel\303\251"), "String not decoded correctly");
284284
zassert_equal(obj_array_array_ts.objects_array[1].objects.height, 173,
285-
"Pelé height not decoded correctly");
285+
"Pel\303\251 height not decoded correctly");
286286

287287
zassert_true(!strcmp(obj_array_array_ts.objects_array[2].objects.name,
288288
"Usain Bolt"), "String not decoded correctly");
@@ -294,23 +294,23 @@ ZTEST(lib_json_test, test_json_obj_arr_encoding)
294294
{
295295
struct obj_array oa = {
296296
.elements = {
297-
[0] = { .name = "Simón Bolívar", .height = 168 },
298-
[1] = { .name = "Muggsy Bogues", .height = 160 },
299-
[2] = { .name = "Pelé", .height = 173 },
300-
[3] = { .name = "Hakeem Olajuwon", .height = 213 },
301-
[4] = { .name = "Alex Honnold", .height = 180 },
302-
[5] = { .name = "Hazel Findlay", .height = 157 },
303-
[6] = { .name = "Daila Ojeda", .height = 158 },
304-
[7] = { .name = "Albert Einstein", .height = 172 },
305-
[8] = { .name = "Usain Bolt", .height = 195 },
306-
[9] = { .name = "Paavo Nurmi", .height = 174 },
297+
[0] = { .name = "Sim\303\263n Bol\303\255var", .height = 168 },
298+
[1] = { .name = "Muggsy Bogues", .height = 160 },
299+
[2] = { .name = "Pel\303\251", .height = 173 },
300+
[3] = { .name = "Hakeem Olajuwon", .height = 213 },
301+
[4] = { .name = "Alex Honnold", .height = 180 },
302+
[5] = { .name = "Hazel Findlay", .height = 157 },
303+
[6] = { .name = "Daila Ojeda", .height = 158 },
304+
[7] = { .name = "Albert Einstein", .height = 172 },
305+
[8] = { .name = "Usain Bolt", .height = 195 },
306+
[9] = { .name = "Paavo Nurmi", .height = 174 },
307307
},
308308
.num_elements = 10,
309309
};
310310
const char encoded[] = "{\"elements\":["
311-
"{\"name\":\"Simón Bolívar\",\"height\":168},"
311+
"{\"name\":\"Sim\303\263n Bol\303\255var\",\"height\":168},"
312312
"{\"name\":\"Muggsy Bogues\",\"height\":160},"
313-
"{\"name\":\"Pelé\",\"height\":173},"
313+
"{\"name\":\"Pel\303\251\",\"height\":173},"
314314
"{\"name\":\"Hakeem Olajuwon\",\"height\":213},"
315315
"{\"name\":\"Alex Honnold\",\"height\":180},"
316316
"{\"name\":\"Hazel Findlay\",\"height\":157},"
@@ -333,8 +333,8 @@ ZTEST(lib_json_test, test_json_arr_obj_decoding)
333333
{
334334
int ret;
335335
struct obj_array obj_array_array_ts;
336-
char encoded[] = "[{\"height\":168,\"name\":\"Simón Bolívar\"},"
337-
"{\"height\":173,\"name\":\"Pelé\"},"
336+
char encoded[] = "[{\"height\":168,\"name\":\"Sim\303\263n Bol\303\255var\"},"
337+
"{\"height\":173,\"name\":\"Pel\303\251\"},"
338338
"{\"height\":195,\"name\":\"Usain Bolt\"}"
339339
"]";
340340

@@ -347,14 +347,14 @@ ZTEST(lib_json_test, test_json_arr_obj_decoding)
347347
"Array doesn't have correct number of items");
348348

349349
zassert_true(!strcmp(obj_array_array_ts.elements[0].name,
350-
"Simón Bolívar"), "String not decoded correctly");
350+
"Sim\303\263n Bol\303\255var"), "String not decoded correctly");
351351
zassert_equal(obj_array_array_ts.elements[0].height, 168,
352-
"Simón Bolívar height not decoded correctly");
352+
"Sim\303\263n Bol\303\255var height not decoded correctly");
353353

354354
zassert_true(!strcmp(obj_array_array_ts.elements[1].name,
355-
"Pelé"), "String not decoded correctly");
355+
"Pel\303\251"), "String not decoded correctly");
356356
zassert_equal(obj_array_array_ts.elements[1].height, 173,
357-
"Pelé height not decoded correctly");
357+
"Pel\303\251 height not decoded correctly");
358358

359359
zassert_true(!strcmp(obj_array_array_ts.elements[2].name,
360360
"Usain Bolt"), "String not decoded correctly");
@@ -366,23 +366,23 @@ ZTEST(lib_json_test, test_json_arr_obj_encoding)
366366
{
367367
struct obj_array oa = {
368368
.elements = {
369-
[0] = { .name = "Simón Bolívar", .height = 168 },
370-
[1] = { .name = "Muggsy Bogues", .height = 160 },
371-
[2] = { .name = "Pelé", .height = 173 },
372-
[3] = { .name = "Hakeem Olajuwon", .height = 213 },
373-
[4] = { .name = "Alex Honnold", .height = 180 },
374-
[5] = { .name = "Hazel Findlay", .height = 157 },
375-
[6] = { .name = "Daila Ojeda", .height = 158 },
376-
[7] = { .name = "Albert Einstein", .height = 172 },
377-
[8] = { .name = "Usain Bolt", .height = 195 },
378-
[9] = { .name = "Paavo Nurmi", .height = 174 },
369+
[0] = { .name = "Sim\303\263n Bol\303\255var", .height = 168 },
370+
[1] = { .name = "Muggsy Bogues", .height = 160 },
371+
[2] = { .name = "Pel\303\251", .height = 173 },
372+
[3] = { .name = "Hakeem Olajuwon", .height = 213 },
373+
[4] = { .name = "Alex Honnold", .height = 180 },
374+
[5] = { .name = "Hazel Findlay", .height = 157 },
375+
[6] = { .name = "Daila Ojeda", .height = 158 },
376+
[7] = { .name = "Albert Einstein", .height = 172 },
377+
[8] = { .name = "Usain Bolt", .height = 195 },
378+
[9] = { .name = "Paavo Nurmi", .height = 174 },
379379
},
380380
.num_elements = 10,
381381
};
382382
char encoded[] = "["
383-
"{\"name\":\"Simón Bolívar\",\"height\":168},"
383+
"{\"name\":\"Sim\303\263n Bol\303\255var\",\"height\":168},"
384384
"{\"name\":\"Muggsy Bogues\",\"height\":160},"
385-
"{\"name\":\"Pelé\",\"height\":173},"
385+
"{\"name\":\"Pel\303\251\",\"height\":173},"
386386
"{\"name\":\"Hakeem Olajuwon\",\"height\":213},"
387387
"{\"name\":\"Alex Honnold\",\"height\":180},"
388388
"{\"name\":\"Hazel Findlay\",\"height\":157},"
@@ -408,9 +408,9 @@ ZTEST(lib_json_test, test_json_obj_arr_decoding)
408408
{
409409
struct obj_array oa;
410410
char encoded[] = "{\"elements\":["
411-
"{\"name\":\"Simón Bolívar\",\"height\":168},"
411+
"{\"name\":\"Sim\303\263n Bol\303\255var\",\"height\":168},"
412412
"{\"name\":\"Muggsy Bogues\",\"height\":160},"
413-
"{\"name\":\"Pelé\",\"height\":173},"
413+
"{\"name\":\"Pel\303\251\",\"height\":173},"
414414
"{\"name\":\"Hakeem Olajuwon\",\"height\":213},"
415415
"{\"name\":\"Alex Honnold\",\"height\":180},"
416416
"{\"name\":\"Hazel Findlay\",\"height\":157},"
@@ -421,16 +421,16 @@ ZTEST(lib_json_test, test_json_obj_arr_decoding)
421421
"]}";
422422
const struct obj_array expected = {
423423
.elements = {
424-
[0] = { .name = "Simón Bolívar", .height = 168 },
425-
[1] = { .name = "Muggsy Bogues", .height = 160 },
426-
[2] = { .name = "Pelé", .height = 173 },
427-
[3] = { .name = "Hakeem Olajuwon", .height = 213 },
428-
[4] = { .name = "Alex Honnold", .height = 180 },
429-
[5] = { .name = "Hazel Findlay", .height = 157 },
430-
[6] = { .name = "Daila Ojeda", .height = 158 },
431-
[7] = { .name = "Albert Einstein", .height = 172 },
432-
[8] = { .name = "Usain Bolt", .height = 195 },
433-
[9] = { .name = "Paavo Nurmi", .height = 174 },
424+
[0] = { .name = "Sim\303\263n Bol\303\255var", .height = 168 },
425+
[1] = { .name = "Muggsy Bogues", .height = 160 },
426+
[2] = { .name = "Pel\303\251", .height = 173 },
427+
[3] = { .name = "Hakeem Olajuwon", .height = 213 },
428+
[4] = { .name = "Alex Honnold", .height = 180 },
429+
[5] = { .name = "Hazel Findlay", .height = 157 },
430+
[6] = { .name = "Daila Ojeda", .height = 158 },
431+
[7] = { .name = "Albert Einstein", .height = 172 },
432+
[8] = { .name = "Usain Bolt", .height = 195 },
433+
[9] = { .name = "Paavo Nurmi", .height = 174 },
434434
},
435435
.num_elements = 10,
436436
};

0 commit comments

Comments
 (0)