Increases MAX_NESTING of json objects/arrays to 2048.

Fixes #75
This commit is contained in:
Krzysztof Gabis 2017-05-08 19:55:29 +01:00
parent dd9eed2af2
commit e410fc7c33
3 changed files with 4 additions and 11 deletions

View File

@ -42,7 +42,7 @@
#define STARTING_CAPACITY 15
#define ARRAY_MAX_CAPACITY 122880 /* 15*(2^13) */
#define OBJECT_MAX_CAPACITY 960 /* 15*(2^6) */
#define MAX_NESTING 19
#define MAX_NESTING 2048
#define DOUBLE_SERIALIZATION_FORMAT "%f"
#define SIZEOF_TOKEN(a) (sizeof(a) - 1)

11
tests.c
View File

@ -86,9 +86,7 @@ void test_suite_1(void) {
TEST(json_value_equals(json_parse_string(json_serialize_to_string_pretty(val)), val));
if (val) { json_value_free(val); }
TEST((val = json_parse_file("tests/test_1_2.txt")) != NULL);
TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val));
TEST(json_value_equals(json_parse_string(json_serialize_to_string_pretty(val)), val));
TEST((val = json_parse_file("tests/test_1_2.txt")) == NULL); /* Over 2048 levels of nesting */
if (val) { json_value_free(val); }
TEST((val = json_parse_file("tests/test_1_3.txt")) != NULL);
@ -101,9 +99,7 @@ void test_suite_1(void) {
TEST(json_value_equals(json_parse_string(json_serialize_to_string_pretty(val)), val));
if (val) { json_value_free(val); }
TEST((val = json_parse_file_with_comments("tests/test_1_2.txt")) != NULL);
TEST(json_value_equals(json_parse_string(json_serialize_to_string(val)), val));
TEST(json_value_equals(json_parse_string(json_serialize_to_string_pretty(val)), val));
TEST((val = json_parse_file_with_comments("tests/test_1_2.txt")) == NULL); /* Over 2048 levels of nesting */
if (val) { json_value_free(val); }
TEST((val = json_parse_file_with_comments("tests/test_1_3.txt")) != NULL);
@ -238,8 +234,6 @@ void test_suite_2_with_comments(void) {
}
void test_suite_3(void) {
char nested_20x[] = "[[[[[[[[[[[[[[[[[[[[\"hi\"]]]]]]]]]]]]]]]]]]]]";
puts("Testing valid strings:");
TEST(json_parse_string("{\"lorem\":\"ipsum\"}") != NULL);
TEST(json_parse_string("[\"lorem\"]") != NULL);
@ -281,7 +275,6 @@ void test_suite_3(void) {
TEST(json_parse_string("[\"\n\"]") == NULL); /* control character */
TEST(json_parse_string("[\"\f\"]") == NULL); /* control character */
TEST(json_parse_string("[\"\r\"]") == NULL); /* control character */
TEST(json_parse_string(nested_20x) == NULL); /* too deep */
TEST(json_parse_string("[0x2]") == NULL); /* hex */
TEST(json_parse_string("[0X2]") == NULL); /* HEX */
TEST(json_parse_string("[07]") == NULL); /* octals */

View File

@ -1 +1 @@
[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[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