Skip to content

Conversation

@Alanscut
Copy link
Collaborator

Changes:

@xiaomianhehe , would you like to review this pr?

str3 = cJSON_PrintUnformatted(root);
TEST_ASSERT_EQUAL_STRING(expected_json3, str3);
free(str3);

Copy link
Contributor

@xiaomianhehe xiaomianhehe Mar 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//To cover more case, add below test would be better?
cJSON_AddItemToArray(array, item1);
cJSON_DeleteItemFromArray(array, 1);
str2 = cJSON_PrintUnformatted(root);
TEST_ASSERT_EQUAL_STRING(expected_json2, str2);
free(str2);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item1 has been freed during cJSON_DeleteItemFromArray(array, 0);, so I have to copy it at first. besides, I think the test you supplemented won't pass: str2 is not equal expected_json2.
could you provide a completely testcase? or use the insert a suggestion(ctrl+g) to give me a more detail clue?

Copy link
Contributor

@xiaomianhehe xiaomianhehe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants