forked from json-c/json-c
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update json_object_new_string_len, json_escape_str (internal). Writer…
… handles \x00 correctly Added parse_null test. This does not change anything with how the parser handles \u0000 or null characters This commit is addapted from one by Adomas Paltanavičius <adomas@leanholding.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@63 327403b1-1117-474d-bef2-5cb71233fd97
- Loading branch information
Showing
7 changed files
with
94 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Tests if binary strings are supported. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include "config.h" | ||
|
||
#include "json_inttypes.h" | ||
#include "json_object.h" | ||
|
||
int main() { | ||
// this test has a space after the null character. check that it's still included | ||
const char *input = " \0 "; | ||
const char *expected = "\" \\u0000 \""; | ||
struct json_object *string = json_object_new_string_len(input, 3); | ||
const char *json = json_object_to_json_string(string); | ||
|
||
int strings_match = !strcmp( expected, json); | ||
int retval = 0; | ||
if (strings_match) { | ||
printf("JSON write result is correct: %s\n", json); | ||
printf("PASS\n"); | ||
} else { | ||
printf("JSON write result doesn't match expected string\n"); | ||
printf("expected string: "); | ||
printf("%s\n", expected); | ||
printf("parsed string: "); | ||
printf("%s\n", json); | ||
printf("FAIL\n"); | ||
retval=1; | ||
} | ||
json_object_put(string); | ||
return retval; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
JSON write result is correct: " \u0000 " | ||
PASS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
# Common definitions | ||
if test -z "$srcdir"; then | ||
srcdir="${0%/*}" | ||
test "$srcdir" = "$0" && srcdir=. | ||
test -z "$srcdir" && srcdir=. | ||
fi | ||
. "$srcdir/test-defs.sh" | ||
|
||
run_output_test test_null | ||
exit $? |