提交 7ed067e6 编写于 作者: S Stephan Gatzka

Rename some variables to avoid shadowing.

上级 4703f01c
...@@ -96,14 +96,14 @@ int main(void) ...@@ -96,14 +96,14 @@ int main(void)
printf("JSON Apply Patch Tests\n"); printf("JSON Apply Patch Tests\n");
for (i = 0; i < 15; i++) for (i = 0; i < 15; i++)
{ {
cJSON *object = cJSON_Parse(patches[i][0]); cJSON *object_to_be_patched = cJSON_Parse(patches[i][0]);
cJSON *patch = cJSON_Parse(patches[i][1]); cJSON *patch = cJSON_Parse(patches[i][1]);
int err = cJSONUtils_ApplyPatches(object, patch); int err = cJSONUtils_ApplyPatches(object_to_be_patched, patch);
char *output = cJSON_Print(object); char *output = cJSON_Print(object_to_be_patched);
printf("Test %d (err %d):\n%s\n\n", i + 1, err, output); printf("Test %d (err %d):\n%s\n\n", i + 1, err, output);
free(output); free(output);
cJSON_Delete(object); cJSON_Delete(object_to_be_patched);
cJSON_Delete(patch); cJSON_Delete(patch);
} }
...@@ -168,19 +168,19 @@ int main(void) ...@@ -168,19 +168,19 @@ int main(void)
printf("JSON Merge Patch tests\n"); printf("JSON Merge Patch tests\n");
for (i = 0; i < 15; i++) for (i = 0; i < 15; i++)
{ {
cJSON *object = cJSON_Parse(merges[i][0]); cJSON *object_to_be_merged = cJSON_Parse(merges[i][0]);
cJSON *patch = cJSON_Parse(merges[i][1]); cJSON *patch = cJSON_Parse(merges[i][1]);
char *before = cJSON_PrintUnformatted(object); char *before_merge = cJSON_PrintUnformatted(object_to_be_merged);
patchtext = cJSON_PrintUnformatted(patch); patchtext = cJSON_PrintUnformatted(patch);
printf("Before: [%s] -> [%s] = ", before, patchtext); printf("Before: [%s] -> [%s] = ", before_merge, patchtext);
object = cJSONUtils_MergePatch(object, patch); object_to_be_merged = cJSONUtils_MergePatch(object_to_be_merged, patch);
after = cJSON_PrintUnformatted(object); after = cJSON_PrintUnformatted(object_to_be_merged);
printf("[%s] vs [%s] (%s)\n", after, merges[i][2], strcmp(after, merges[i][2]) ? "FAIL" : "OK"); printf("[%s] vs [%s] (%s)\n", after, merges[i][2], strcmp(after, merges[i][2]) ? "FAIL" : "OK");
free(before); free(before_merge);
free(patchtext); free(patchtext);
free(after); free(after);
cJSON_Delete(object); cJSON_Delete(object_to_be_merged);
cJSON_Delete(patch); cJSON_Delete(patch);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册