Skip to content

Commit c66f088

Browse files
nandojvejhedberg
authored andcommitted
tests: lib: json: fix test expectation
Update the test_json_decoding test to expect correct unescaped values based on descriptor type semantics: - JSON_TOK_STRING: Stores pointer to original JSON string, preserving escape sequences as they appear in the source. Used when the original escaped format needs to be maintained. - JSON_TOK_STRING_BUF: Copies and unescapes the string into a fixed-size buffer, converting JSON escape sequences (\n, \t, \", etc.) to their actual character equivalents. Used when the processed, unescaped string is needed. The test was incorrectly expecting the nested_string_buf field (which uses JSON_TOK_STRING_BUF) to contain the escaped form "esc: \\t". With the proper unescaping implementation, this field should contain the unescaped version "esc: \t" (with actual tab character). This aligns with the documented behavior where JSON_TOK_STRING_BUF performs unescaping during the copy operation, while JSON_TOK_STRING simply references the original escaped string. Signed-off-by: BUDKE Gerson Fernando <gerson.budke@leica-geosystems.com>
1 parent 66d13d7 commit c66f088

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

tests/lib/json/src/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,7 @@ ZTEST(lib_json_test, test_json_decoding)
554554
zassert_str_equal(ts.some_nested_struct.nested_string,
555555
"this should be escaped: \\t",
556556
"Nested string not decoded correctly");
557-
zassert_str_equal(ts.some_nested_struct.nested_string_buf,
558-
"esc: \\t",
557+
zassert_str_equal(ts.some_nested_struct.nested_string_buf, "esc: \t",
559558
"Nested string-array not decoded correctly");
560559
zassert_equal(ts.some_array_len, 5,
561560
"Array doesn't have correct number of items");

0 commit comments

Comments
 (0)