# HG changeset patch # User Olaf Wintermann # Date 1765639841 -3600 # Node ID 7ab8b302d187a36dcd47a63d91bcbb27ae411132 # Parent 5c4ee11417c10b896d8b87575c010712f7ba9d6b add json array compare tests diff -r 5c4ee11417c1 -r 7ab8b302d187 tests/test_json.c --- a/tests/test_json.c Sat Dec 13 16:27:24 2025 +0100 +++ b/tests/test_json.c Sat Dec 13 16:30:41 2025 +0100 @@ -1416,8 +1416,31 @@ } CX_TEST(test_json_compare_arrays) { + char *str[4]; + str[0] = "[]"; + str[1] = "[ true, false ]"; + str[2] = "[ 0, 1, \"hello\", true, false, null, {}, {\"a\":\"b\"}]"; + str[3] = "[ \"test\", [ 1, 2, [ \"sub\", \"sub1\", [{\"end\":null}]]]]"; + + CxJsonValue *a[4]; + CxJsonValue *b[4]; + for(int i=0;i<4;i++) { + cxJsonFromString(NULL, str[i], &a[i]); + cxJsonFromString(NULL, str[i], &b[i]); + } + CX_TEST_DO { - + for(int i=0;i<4;i++) { + for(int j=0;j<4;j++) { + int ret = cxJsonCompare(a[i], b[j]); + CX_TEST_ASSERT(i == j ? ret == 0 : ret != 0); + } + } + } + + for(int i=0;i<4;i++) { + cxJsonValueFree(a[i]); + cxJsonValueFree(b[i]); } }