forked from bblanchon/ArduinoJson
Preallocate pool list
This commit is contained in:
@ -281,7 +281,7 @@ TEST_CASE("deserialize JSON array under memory constraints") {
|
||||
}
|
||||
|
||||
SECTION("allocation of pool fails") {
|
||||
allocator.setCountdown(1);
|
||||
allocator.setCountdown(0);
|
||||
char input[] = "[1]";
|
||||
|
||||
DeserializationError err = deserializeJson(doc, input);
|
||||
@ -291,7 +291,7 @@ TEST_CASE("deserialize JSON array under memory constraints") {
|
||||
}
|
||||
|
||||
SECTION("allocation of string fails in array") {
|
||||
allocator.setCountdown(2);
|
||||
allocator.setCountdown(1);
|
||||
char input[] = "[0,\"hi!\"]";
|
||||
|
||||
DeserializationError err = deserializeJson(doc, input);
|
||||
|
@ -344,7 +344,7 @@ TEST_CASE("deserialize JSON object under memory constraints") {
|
||||
REQUIRE(doc.as<std::string>() == "{}");
|
||||
}
|
||||
|
||||
SECTION("pool list allocation fails") {
|
||||
SECTION("pool allocation fails") {
|
||||
allocator.setCountdown(2);
|
||||
char input[] = "{\"a\":1}";
|
||||
|
||||
@ -354,18 +354,8 @@ TEST_CASE("deserialize JSON object under memory constraints") {
|
||||
REQUIRE(doc.as<std::string>() == "{}");
|
||||
}
|
||||
|
||||
SECTION("pool allocation fails") {
|
||||
allocator.setCountdown(3);
|
||||
char input[] = "{\"a\":1}";
|
||||
|
||||
DeserializationError err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
REQUIRE(doc.as<std::string>() == "{}");
|
||||
}
|
||||
|
||||
SECTION("string allocation fails") {
|
||||
allocator.setCountdown(4);
|
||||
allocator.setCountdown(3);
|
||||
char input[] = "{\"a\":\"b\"}";
|
||||
|
||||
DeserializationError err = deserializeJson(doc, input);
|
||||
|
@ -111,14 +111,13 @@ TEST_CASE("Allocation of the key fails") {
|
||||
}
|
||||
|
||||
SECTION("Quoted string, second member") {
|
||||
timebombAllocator.setCountdown(4);
|
||||
timebombAllocator.setCountdown(3);
|
||||
REQUIRE(deserializeJson(doc, "{\"hello\":1,\"world\"}") ==
|
||||
DeserializationError::NoMemory);
|
||||
REQUIRE(spyingAllocator.log() ==
|
||||
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
|
||||
<< AllocatorLog::Reallocate(sizeofString(31),
|
||||
sizeofString(5))
|
||||
<< AllocatorLog::Allocate(sizeofPoolList())
|
||||
<< AllocatorLog::Allocate(sizeofPool())
|
||||
<< AllocatorLog::AllocateFail(sizeofString(31)));
|
||||
}
|
||||
@ -131,14 +130,13 @@ TEST_CASE("Allocation of the key fails") {
|
||||
}
|
||||
|
||||
SECTION("Non-Quoted string, second member") {
|
||||
timebombAllocator.setCountdown(4);
|
||||
timebombAllocator.setCountdown(3);
|
||||
REQUIRE(deserializeJson(doc, "{hello:1,world}") ==
|
||||
DeserializationError::NoMemory);
|
||||
REQUIRE(spyingAllocator.log() ==
|
||||
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
|
||||
<< AllocatorLog::Reallocate(sizeofString(31),
|
||||
sizeofString(5))
|
||||
<< AllocatorLog::Allocate(sizeofPoolList())
|
||||
<< AllocatorLog::Allocate(sizeofPool())
|
||||
<< AllocatorLog::AllocateFail(sizeofString(31)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user