mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Merge pull request #4 from irwand/fix_division_by_zero_test
Fix compiler div-by-0 error when it encountered 1.0/0.0
This commit is contained in:
commit
4488c2b5ad
3
test.c
3
test.c
@ -68,6 +68,7 @@ void create_objects()
|
|||||||
struct record fields[2]={
|
struct record fields[2]={
|
||||||
{"zip",37.7668,-1.223959e+2,"","SAN FRANCISCO","CA","94107","US"},
|
{"zip",37.7668,-1.223959e+2,"","SAN FRANCISCO","CA","94107","US"},
|
||||||
{"zip",37.371991,-1.22026e+2,"","SUNNYVALE","CA","94085","US"}};
|
{"zip",37.371991,-1.22026e+2,"","SUNNYVALE","CA","94085","US"}};
|
||||||
|
volatile double zero = 0.0;
|
||||||
|
|
||||||
/* Here we construct some JSON standards, from the JSON site. */
|
/* Here we construct some JSON standards, from the JSON site. */
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ void create_objects()
|
|||||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
||||||
|
|
||||||
root=cJSON_CreateObject();
|
root=cJSON_CreateObject();
|
||||||
cJSON_AddNumberToObject(root,"number", 1.0/0.0);
|
cJSON_AddNumberToObject(root,"number", 1.0/zero);
|
||||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user