Update Json-c from 0.11 to 0.12
This commit is contained in:
40
3P/json/tests/test_charcase.c
Normal file
40
3P/json/tests/test_charcase.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "json.h"
|
||||
#include "json_tokener.h"
|
||||
|
||||
static void test_case_parse(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MC_SET_DEBUG(1);
|
||||
|
||||
test_case_parse();
|
||||
}
|
||||
|
||||
/* make sure only lowercase forms are parsed in strict mode */
|
||||
static void test_case_parse()
|
||||
{
|
||||
struct json_tokener *tok;
|
||||
json_object *new_obj;
|
||||
|
||||
tok = json_tokener_new();
|
||||
json_tokener_set_flags(tok, JSON_TOKENER_STRICT);
|
||||
|
||||
new_obj = json_tokener_parse_ex(tok, "True", 4);
|
||||
assert (new_obj == NULL);
|
||||
|
||||
new_obj = json_tokener_parse_ex(tok, "False", 5);
|
||||
assert (new_obj == NULL);
|
||||
|
||||
new_obj = json_tokener_parse_ex(tok, "Null", 4);
|
||||
assert (new_obj == NULL);
|
||||
|
||||
printf("OK\n");
|
||||
|
||||
json_tokener_free(tok);
|
||||
}
|
||||
1
3P/json/tests/test_charcase.expected
Normal file
1
3P/json/tests/test_charcase.expected
Normal file
@@ -0,0 +1 @@
|
||||
OK
|
||||
2
3P/json/tests/parse_int64.test → 3P/json/tests/test_charcase.test
Executable file → Normal file
2
3P/json/tests/parse_int64.test → 3P/json/tests/test_charcase.test
Executable file → Normal file
@@ -8,5 +8,5 @@ if test -z "$srcdir"; then
|
||||
fi
|
||||
. "$srcdir/test-defs.sh"
|
||||
|
||||
run_output_test test_parse_int64
|
||||
run_output_test test_charcase
|
||||
exit $?
|
||||
@@ -1,2 +1,2 @@
|
||||
new_obj.to_string()=[ 1.200000, 3.400000, 123456.780000, 5.000000, 23000000000.000000 ]
|
||||
new_obj.to_string()=[1.2,3.4,123456.78,5.0,23000000000.0]
|
||||
new_obj.to_string()=[ 1.2, 3.4, 123456.78, 5.0, 2.3e10 ]
|
||||
new_obj.to_string()=[1.2,3.4,123456.78,5.0,2.3e10]
|
||||
|
||||
@@ -47,6 +47,38 @@ 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");
|
||||
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);
|
||||
|
||||
@@ -3,9 +3,17 @@ new_obj.to_string()="foo"
|
||||
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.300000
|
||||
new_obj.to_string()=12.3
|
||||
new_obj.to_string()=[ "\n" ]
|
||||
new_obj.to_string()=[ "\nabc\n" ]
|
||||
new_obj.to_string()=[ null ]
|
||||
|
||||
Reference in New Issue
Block a user