summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Haszlakiewicz <erh+git@nimenees.com>2014-03-22 17:28:40 -0400
committerEric Haszlakiewicz <erh+git@nimenees.com>2014-03-22 17:28:40 -0400
commit05da316b9ceee79fa98575133d9f4c9e2abe59d0 (patch)
treef42b8845dae79f8fddefdeb6504914f5cddc73cd /tests
parent217bc29352de00e8cd24edb789784e1f30339414 (diff)
downloadjson-c-05da316b9ceee79fa98575133d9f4c9e2abe59d0.tar.gz
Issue #103: allow Infinity and -Infinity to be parsed.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_parse.c28
-rw-r--r--tests/test_parse.expected7
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_parse.c b/tests/test_parse.c
index f0f2550..8808d0f 100644
--- a/tests/test_parse.c
+++ b/tests/test_parse.c
@@ -51,6 +51,34 @@ static void test_basic_parse()
printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
json_object_put(new_obj);
+ new_obj = json_tokener_parse("-NaN"); /* non-sensical, returns null */
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
+ new_obj = json_tokener_parse("Inf"); /* must use full string, returns null */
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
+ new_obj = json_tokener_parse("inf"); /* must use full string, returns null */
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
+ new_obj = json_tokener_parse("Infinity");
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
+ new_obj = json_tokener_parse("infinity");
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
+ new_obj = json_tokener_parse("-Infinity");
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
+ new_obj = json_tokener_parse("-infinity");
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
new_obj = json_tokener_parse("True");
printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
json_object_put(new_obj);
diff --git a/tests/test_parse.expected b/tests/test_parse.expected
index 378a82b..d49cbbb 100644
--- a/tests/test_parse.expected
+++ b/tests/test_parse.expected
@@ -4,6 +4,13 @@ new_obj.to_string()="foo"
new_obj.to_string()="ABC"
new_obj.to_string()=null
new_obj.to_string()=NaN
+new_obj.to_string()=null
+new_obj.to_string()=null
+new_obj.to_string()=null
+new_obj.to_string()=Infinity
+new_obj.to_string()=Infinity
+new_obj.to_string()=-Infinity
+new_obj.to_string()=-Infinity
new_obj.to_string()=true
new_obj.to_string()=12
new_obj.to_string()=12.3