forked from bblanchon/ArduinoJson
Made nestingLimit a member of the document
This commit is contained in:
@ -12,21 +12,23 @@ TEST_CASE("JsonDeserializer nestingLimit") {
|
||||
DynamicJsonDocument doc;
|
||||
|
||||
SECTION("limit = 0") {
|
||||
SHOULD_WORK(deserializeJson(doc, "\"toto\"", 0));
|
||||
SHOULD_WORK(deserializeJson(doc, "123", 0));
|
||||
SHOULD_WORK(deserializeJson(doc, "true", 0));
|
||||
SHOULD_FAIL(deserializeJson(doc, "[]", 0));
|
||||
SHOULD_FAIL(deserializeJson(doc, "{}", 0));
|
||||
SHOULD_FAIL(deserializeJson(doc, "[\"toto\"]", 0));
|
||||
SHOULD_FAIL(deserializeJson(doc, "{\"toto\":1}", 0));
|
||||
doc.nestingLimit = 0;
|
||||
SHOULD_WORK(deserializeJson(doc, "\"toto\""));
|
||||
SHOULD_WORK(deserializeJson(doc, "123"));
|
||||
SHOULD_WORK(deserializeJson(doc, "true"));
|
||||
SHOULD_FAIL(deserializeJson(doc, "[]"));
|
||||
SHOULD_FAIL(deserializeJson(doc, "{}"));
|
||||
SHOULD_FAIL(deserializeJson(doc, "[\"toto\"]"));
|
||||
SHOULD_FAIL(deserializeJson(doc, "{\"toto\":1}"));
|
||||
}
|
||||
|
||||
SECTION("limit = 1") {
|
||||
SHOULD_WORK(deserializeJson(doc, "[\"toto\"]", 1));
|
||||
SHOULD_WORK(deserializeJson(doc, "{\"toto\":1}", 1));
|
||||
SHOULD_FAIL(deserializeJson(doc, "{\"toto\":{}}", 1));
|
||||
SHOULD_FAIL(deserializeJson(doc, "{\"toto\":[]}", 1));
|
||||
SHOULD_FAIL(deserializeJson(doc, "[[\"toto\"]]", 1));
|
||||
SHOULD_FAIL(deserializeJson(doc, "[{\"toto\":1}]", 1));
|
||||
doc.nestingLimit = 1;
|
||||
SHOULD_WORK(deserializeJson(doc, "[\"toto\"]"));
|
||||
SHOULD_WORK(deserializeJson(doc, "{\"toto\":1}"));
|
||||
SHOULD_FAIL(deserializeJson(doc, "{\"toto\":{}}"));
|
||||
SHOULD_FAIL(deserializeJson(doc, "{\"toto\":[]}"));
|
||||
SHOULD_FAIL(deserializeJson(doc, "[[\"toto\"]]"));
|
||||
SHOULD_FAIL(deserializeJson(doc, "[{\"toto\":1}]"));
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@
|
||||
|
||||
static void check(const char* input, MsgPackError expected,
|
||||
uint8_t nestingLimit = 10) {
|
||||
DynamicJsonDocument variant;
|
||||
DynamicJsonDocument doc;
|
||||
doc.nestingLimit = nestingLimit;
|
||||
|
||||
MsgPackError error = deserializeMsgPack(variant, input, nestingLimit);
|
||||
MsgPackError error = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(error == expected);
|
||||
}
|
||||
|
Reference in New Issue
Block a user