diff options
Diffstat (limited to 'tests/test1.c')
-rw-r--r-- | tests/test1.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test1.c b/tests/test1.c index 6682120..4d29601 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -1,9 +1,12 @@ #include <assert.h> +#include <limits.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "config.h" + #include "json.h" #include "parse_flags.h" @@ -307,6 +310,27 @@ int main(int argc, char **argv) } printf("my_object.to_string()=%s\n", json_object_to_json_string(my_object)); + json_object_put(my_array); + my_array = json_object_new_array_ext(INT_MIN + 1); + if (my_array != NULL) + { + printf("ERROR: able to allocate an array of negative size!\n"); + fflush(stdout); + json_object_put(my_array); + my_array = NULL; + } + +#if SIZEOF_SIZE_T == SIZEOF_INT + my_array = json_object_new_array_ext(INT_MAX / 2 + 2); + if (my_array != NULL) + { + printf("ERROR: able to allocate an array of insufficient size!\n"); + fflush(stdout); + json_object_put(my_array); + my_array = NULL; + } +#endif + json_object_put(my_string); json_object_put(my_int); json_object_put(my_null); |