cJSON

mirror of Dave's cJSON
git clone git://git.thc420.xyz/cJSON
Log | Files | Refs | README | LICENSE

commit 9e310491597151fcf783191fd5df05c363b09b50
parent 8ac1ba416e7f1365575b5d9c1ea7941c4af5bf2d
Author: Max Bruckner <max@maxbruckner.de>
Date:   Sat,  5 Nov 2016 16:52:09 +0700

test and test_utils: Make compliant with ANSI C

Diffstat:
Mtest.c | 4++--
Mtest_utils.c | 18++++++++++++------
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/test.c b/test.c @@ -82,7 +82,7 @@ struct record }; /* Create a bunch of objects as demonstration. */ -void create_objects() +void create_objects(void) { /* declare a few. */ cJSON *root; @@ -231,7 +231,7 @@ void create_objects() free(out); } -int main (int argc, const char *argv[]) +int main(void) { /* a bunch of json: */ char text1[] = diff --git a/test_utils.c b/test_utils.c @@ -3,8 +3,13 @@ #include <string.h> #include "cJSON_Utils.h" -int main() +int main(void) { + /* Some variables */ + char *temp = NULL; + char *patchtext = NULL; + char *patchedtext = NULL; + int i; /* JSON Pointer tests: */ cJSON *root; @@ -110,7 +115,7 @@ int main() nums=cJSON_CreateIntArray(numbers,10); num6=cJSON_GetArrayItem(nums,6); cJSON_AddItemToObject(object,"numbers",nums); - char *temp=cJSONUtils_FindPointerFromObjectTo(object,num6); + temp=cJSONUtils_FindPointerFromObjectTo(object,num6); printf("Pointer: [%s]\n",temp); free(temp); temp=cJSONUtils_FindPointerFromObjectTo(object,nums); @@ -140,10 +145,10 @@ int main() cJSON *object=cJSON_Parse(merges[i][0]); cJSON *patch=cJSON_Parse(merges[i][1]); char *before=cJSON_PrintUnformatted(object); - char *patchtext=cJSON_PrintUnformatted(patch); + patchtext=cJSON_PrintUnformatted(patch); printf("Before: [%s] -> [%s] = ",before,patchtext); object=cJSONUtils_MergePatch(object,patch); - char *after=cJSON_PrintUnformatted(object); + after=cJSON_PrintUnformatted(object); printf("[%s] vs [%s] (%s)\n",after,merges[i][2],strcmp(after,merges[i][2])?"FAIL":"OK"); free(before);free(patchtext);free(after);cJSON_Delete(object);cJSON_Delete(patch); @@ -156,10 +161,11 @@ int main() cJSON *to=cJSON_Parse(merges[i][2]); cJSON *patch=cJSONUtils_GenerateMergePatch(from,to); from=cJSONUtils_MergePatch(from,patch); - char *patchtext=cJSON_PrintUnformatted(patch); - char *patchedtext=cJSON_PrintUnformatted(from); + patchtext=cJSON_PrintUnformatted(patch); + patchedtext=cJSON_PrintUnformatted(from); printf("Patch [%s] vs [%s] = [%s] vs [%s] (%s)\n",patchtext,merges[i][1],patchedtext,merges[i][2],strcmp(patchedtext,merges[i][2])?"FAIL":"OK"); cJSON_Delete(from);cJSON_Delete(to);cJSON_Delete(patch);free(patchtext);free(patchedtext); } + return 0; }