summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Haszlakiewicz <erh+git@nimenees.com>2012-12-09 16:32:11 -0600
committerEric Haszlakiewicz <erh+git@nimenees.com>2012-12-09 16:32:11 -0600
commit4e4af93d667ae0d3cb9779f5a3c3f964cc9d7d81 (patch)
treef2e3dc1f7de1def9f360dd03cc7b075507b4b173 /tests
parent7a4506d6df902001a4261358ed0e04f66ac092d7 (diff)
Fix issue #53 - ensure explicit length string are still NUL terminated, and fix json_tokener_parse() to work properly with embedded unicode \u0000 values in strings.
Adjust test_null to check for this case. See also http://bugs.debian.org/687269
Diffstat (limited to 'tests')
-rw-r--r--tests/test_null.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_null.c b/tests/test_null.c
index 675eab5..1f07910 100644
--- a/tests/test_null.c
+++ b/tests/test_null.c
@@ -8,6 +8,7 @@
#include "json_inttypes.h"
#include "json_object.h"
+#include "json_tokener.h"
int main()
{
@@ -33,5 +34,24 @@ int main()
retval=1;
}
json_object_put(string);
+
+ struct json_object *parsed_str = json_tokener_parse(expected);
+ if (parsed_str)
+ {
+ int parsed_len = json_object_get_string_len(parsed_str);
+ const char *parsed_cstr = json_object_get_string(parsed_str);
+ int ii;
+ printf("Re-parsed object string len=%d, chars=[", parsed_len);
+ for (ii = 0; ii < parsed_len ; ii++)
+ {
+ printf("%s%d", (ii ? ", " : ""), (int)parsed_cstr[ii]);
+ }
+ printf("]\n");
+ json_object_put(parsed_str);
+ }
+ else
+ {
+ printf("ERROR: failed to parse\n");
+ }
return retval;
}