|
|
|
@ -65,7 +65,7 @@ static int primitive( void ) { |
|
|
|
|
"\"boolvar1\": true," |
|
|
|
|
"\"nullvar\": null," |
|
|
|
|
"\"scientific\": 5368.32e-3," |
|
|
|
|
"\"real\": -0.004," |
|
|
|
|
"\"real\": -0.25," |
|
|
|
|
"}"; |
|
|
|
|
|
|
|
|
|
json_t const* json = json_create( str, pool, qty ); |
|
|
|
@ -103,8 +103,8 @@ static int primitive( void ) { |
|
|
|
|
json_t const* real = json_getProperty( json, "real" ); |
|
|
|
|
check( real ); |
|
|
|
|
check( JSON_REAL == json_getType( real ) ); |
|
|
|
|
check( !strcmp( "-0.004", json_getValue( real ) ) ); |
|
|
|
|
check( -0.004 == json_getReal( real ) );
|
|
|
|
|
check( !strcmp( "-0.25", json_getValue( real ) ) ); |
|
|
|
|
check( -0.25 == json_getReal( real ) ); |
|
|
|
|
|
|
|
|
|
json_t const* scientific = json_getProperty( json, "scientific" ); |
|
|
|
|
check( scientific ); |
|
|
|
@ -135,6 +135,48 @@ static int text( void ) { |
|
|
|
|
done(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int goodformats( void ) { |
|
|
|
|
json_t pool[4]; |
|
|
|
|
unsigned const qty = sizeof pool / sizeof *pool; |
|
|
|
|
{ |
|
|
|
|
char str[] = "{\"qwerty\":false,}"; |
|
|
|
|
json_t const* root = json_create( str, pool, qty ); |
|
|
|
|
check( root ); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
char str[] = "{\"a\":[0,]}"; |
|
|
|
|
json_t const* root = json_create( str, pool, qty ); |
|
|
|
|
check( root ); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
char str[] = "{\"a\":[0],}"; |
|
|
|
|
json_t const* root = json_create( str, pool, qty ); |
|
|
|
|
check( root ); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
char str[] = "{\"qwerty\":654,}"; |
|
|
|
|
json_t const* root = json_create( str, pool, qty ); |
|
|
|
|
check( root ); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
char str[] = "{\"qwerty\":\"asdfgh\",}"; |
|
|
|
|
json_t const* root = json_create( str, pool, qty ); |
|
|
|
|
check( root ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
char str[] = "{,\"qwerty\":\"asdfgh\",}"; |
|
|
|
|
json_t const* root = json_create( str, pool, qty ); |
|
|
|
|
check( root ); |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
char str[] = "{,\"a\":1, , \"b\":2,,,,}"; |
|
|
|
|
json_t const* root = json_create( str, pool, qty ); |
|
|
|
|
check( root ); |
|
|
|
|
} |
|
|
|
|
done(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int array( void ) { |
|
|
|
|
json_t pool[7]; |
|
|
|
|
unsigned const qty = sizeof pool / sizeof *pool; |
|
|
|
@ -217,7 +259,11 @@ int badformat( void ) { |
|
|
|
|
json_t const* json = json_create( str, pool, qty ); |
|
|
|
|
check( json ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
char str[] = "{\"var\":,9}"; |
|
|
|
|
json_t const* json = json_create( str, pool, qty ); |
|
|
|
|
check( !json ); |
|
|
|
|
} |
|
|
|
|
done(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -241,6 +287,7 @@ static struct test const tests[] = { |
|
|
|
|
{ text, "Text" }, |
|
|
|
|
{ array, "Array" }, |
|
|
|
|
{ badformat, "Bad format" }, |
|
|
|
|
{ goodformats, "Formats" }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
int main( void ) { |
|
|
|
|