Update Json-c from 0.11 to 0.12

This commit is contained in:
2016-02-26 22:34:09 +01:00
parent 6bc8cdeef3
commit 9bfae91f93
34 changed files with 1336 additions and 245 deletions

View 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);
}

View File

@@ -0,0 +1 @@
OK

View 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 $?

View File

@@ -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]

View File

@@ -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);

View File

@@ -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 ]