Skip to content

Commit

Permalink
Add ReplaceItemViaPointer update to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Logan Buth committed May 19, 2024
1 parent 105eae4 commit ddb7df0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/misc_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@ static void cjson_replace_item_in_object_should_preserve_name(void)
TEST_ASSERT_TRUE(root->child == replacement);
TEST_ASSERT_EQUAL_STRING("child", replacement->string);

// now test the same, but with replaceitemviapointer
child = cJSON_GetObjectItemCaseSensitive(root, "child");
TEST_ASSERT_NOT_NULL(child);
replacement = cJSON_CreateNumber(3);
TEST_ASSERT_NOT_NULL(replacement);
cJSON_ReplaceItemViaPointer(root, child, replacement);

TEST_ASSERT_TRUE(root->child == replacement);
TEST_ASSERT_EQUAL_STRING("child", replacement->string);

cJSON_Delete(replacement);
}

Expand Down

0 comments on commit ddb7df0

Please sign in to comment.