MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / json_pointer_tests

Function json_pointer_tests

tests/old_utils_tests.c:52–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50};
51
52static void json_pointer_tests(void)
53{
54 cJSON *root = NULL;
55 const char *json=
56 "{"
57 "\"foo\": [\"bar\", \"baz\"],"
58 "\"\": 0,"
59 "\"a/b\": 1,"
60 "\"c%d\": 2,"
61 "\"e^f\": 3,"
62 "\"g|h\": 4,"
63 "\"i\\\\j\": 5,"
64 "\"k\\\"l\": 6,"
65 "\" \": 7,"
66 "\"m~n\": 8"
67 "}";
68
69 root = cJSON_Parse(json);
70
71 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, ""), root);
72 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/foo"), cJSON_GetObjectItem(root, "foo"));
73 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/foo/0"), cJSON_GetObjectItem(root, "foo")->child);
74 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/foo/0"), cJSON_GetObjectItem(root, "foo")->child);
75 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/"), cJSON_GetObjectItem(root, ""));
76 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/a~1b"), cJSON_GetObjectItem(root, "a/b"));
77 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/c%d"), cJSON_GetObjectItem(root, "c%d"));
78 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/c^f"), cJSON_GetObjectItem(root, "c^f"));
79 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/c|f"), cJSON_GetObjectItem(root, "c|f"));
80 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/i\\j"), cJSON_GetObjectItem(root, "i\\j"));
81 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/k\"l"), cJSON_GetObjectItem(root, "k\"l"));
82 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/ "), cJSON_GetObjectItem(root, " "));
83 TEST_ASSERT_EQUAL_PTR(cJSONUtils_GetPointer(root, "/m~0n"), cJSON_GetObjectItem(root, "m~n"));
84
85 cJSON_Delete(root);
86}
87
88static void misc_tests(void)
89{

Callers

nothing calls this directly

Calls 4

cJSON_ParseFunction · 0.85
cJSONUtils_GetPointerFunction · 0.85
cJSON_GetObjectItemFunction · 0.85
cJSON_DeleteFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…