More tests are added.

pull/1/head
rafagafe 7 years ago
parent 37937178bc
commit 03665370ba
  1. 65
      tests.c

@ -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();
}
@ -236,11 +282,12 @@ static int test_exec( struct test const* test ) {
}
static struct test const tests[] = {
{ empty, "Empty object and array" },
{ primitive, "Primitive properties" },
{ text, "Text" },
{ array, "Array" },
{ badformat, "Bad format" },
{ empty, "Empty object and array" },
{ primitive, "Primitive properties" },
{ text, "Text" },
{ array, "Array" },
{ badformat, "Bad format" },
{ goodformats, "Formats" },
};
int main( void ) {

Loading…
Cancel
Save