# HG changeset patch # User Mike Becker # Date 1730575198 -3600 # Node ID 96bf02371aef944248c61c94392aa8f8b5afd91a # Parent ed44741d8ab5531bf7f41c57e8e5a31f724cac94 adds test case for numbers - currently fails due to issue #482 diff -r ed44741d8ab5 -r 96bf02371aef tests/test_json.c --- a/tests/test_json.c Sat Nov 02 20:17:38 2024 +0100 +++ b/tests/test_json.c Sat Nov 02 20:19:58 2024 +0100 @@ -250,9 +250,19 @@ CxJson json; cxJsonInit(&json); CX_TEST_DO { + // TODO: find a better way to terminate values that are not arrays/objects CxJsonValue *v; - - cxJsonNext(&json, &v); + int result; + cxJsonFill(&json, "3.1415 "); + result = cxJsonNext(&json, &v); + CX_TEST_ASSERT(result == 1); + CX_TEST_ASSERT(cxJsonIsNumber(v)); + CX_TEST_ASSERT(cxJsonAsDouble(v) == 3.1415); + cxJsonFill(&json, "-47.11e2 "); + result = cxJsonNext(&json, &v); + CX_TEST_ASSERT(result == 1); + CX_TEST_ASSERT(cxJsonIsNumber(v)); + CX_TEST_ASSERT(cxJsonAsDouble(v) == -4711.0); } cxJsonDestroy(&json); } @@ -265,6 +275,7 @@ cx_test_register(suite, test_json_object_incomplete_token); cx_test_register(suite, test_json_object_error); cx_test_register(suite, test_json_large_nesting_depth); + cx_test_register(suite, test_json_number); return suite; }