tests/test_json.c

changeset 1075
0cc4b63a0ae0
parent 1072
c89283cd559b
child 1078
ffa8bb4e9288
--- a/tests/test_json.c	Wed Jan 01 15:50:57 2025 +0100
+++ b/tests/test_json.c	Wed Jan 01 15:56:02 2025 +0100
@@ -194,13 +194,18 @@
 }
 
 CX_TEST(test_json_token_wrongly_completed) {
+    CxTestingAllocator talloc;
+    cx_testing_allocator_init(&talloc);
+    const CxAllocator *alloc = &talloc.base;
+
     cxstring text = cx_str("{\"number\": 47110815!}");
     cxstring part1 = cx_strsubsl(text, 0, 16);
     cxstring part2 = cx_strsubs(text, 16);
 
-    CxJson json;
-    cxJsonInit(&json, NULL);
     CX_TEST_DO {
+        CxJson json;
+        cxJsonInit(&json, alloc);
+
         CxJsonStatus result;
         CxJsonValue *obj;
 
@@ -211,8 +216,11 @@
         result = cxJsonNext(&json, &obj);
         CX_TEST_ASSERT(result == CX_JSON_FORMAT_ERROR_NUMBER);
         CX_TEST_ASSERT(obj->type == CX_JSON_NOTHING);
+
+        cxJsonDestroy(&json);
+        CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
     }
-    cxJsonDestroy(&json);
+    cx_testing_allocator_destroy(&talloc);
 }
 
 CX_TEST(test_json_subsequent_fill) {

mercurial