From 30ec50798914b0825a7c51c4ac4942c2ee330b8b Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 25 Jul 2023 14:53:54 +0200 Subject: [PATCH] Tests: use a consistent naming convention for allocators --- extras/tests/Cpp17/string_view.cpp | 12 +- extras/tests/JsonArray/add.cpp | 44 +- extras/tests/JsonArray/clear.cpp | 8 +- extras/tests/JsonArray/remove.cpp | 8 +- extras/tests/JsonArray/subscript.cpp | 20 +- extras/tests/JsonDeserializer/array.cpp | 24 +- extras/tests/JsonDeserializer/filter.cpp | 6 +- extras/tests/JsonDeserializer/input_types.cpp | 20 +- extras/tests/JsonDeserializer/misc.cpp | 10 +- extras/tests/JsonDeserializer/object.cpp | 49 +- extras/tests/JsonDeserializer/string.cpp | 102 +-- extras/tests/JsonDocument/MemberProxy.cpp | 28 +- extras/tests/JsonDocument/add.cpp | 36 +- extras/tests/JsonDocument/overflowed.cpp | 30 +- extras/tests/JsonObject/copy.cpp | 48 +- extras/tests/JsonObject/subscript.cpp | 58 +- extras/tests/JsonVariant/clear.cpp | 10 +- extras/tests/JsonVariant/remove.cpp | 26 +- extras/tests/JsonVariant/set.cpp | 28 +- extras/tests/Misc/printable.cpp | 76 +- .../deserializeVariant.cpp | 4 +- extras/tests/MsgPackDeserializer/filter.cpp | 688 +++++++++--------- extras/tests/ResourceManager/shrinkToFit.cpp | 3 +- extras/tests/ResourceManager/size.cpp | 6 +- extras/tests/ResourceManager/swap.cpp | 52 +- 25 files changed, 698 insertions(+), 698 deletions(-) diff --git a/extras/tests/Cpp17/string_view.cpp b/extras/tests/Cpp17/string_view.cpp index 143f61ed..7bd96361 100644 --- a/extras/tests/Cpp17/string_view.cpp +++ b/extras/tests/Cpp17/string_view.cpp @@ -13,8 +13,8 @@ using ArduinoJson::detail::sizeofArray; using ArduinoJson::detail::sizeofString; TEST_CASE("string_view") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); JsonVariant variant = doc.to(); SECTION("deserializeJson()") { @@ -63,10 +63,10 @@ TEST_CASE("string_view") { doc.add(std::string_view("example\0tree", 12)); doc.add(std::string_view("example\0tree and a half", 12)); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7)) - << AllocatorLog::Allocate(sizeofString(12))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7)) + << AllocatorLog::Allocate(sizeofString(12))); } SECTION("as()") { diff --git a/extras/tests/JsonArray/add.cpp b/extras/tests/JsonArray/add.cpp index b3c7e91f..a248dd37 100644 --- a/extras/tests/JsonArray/add.cpp +++ b/extras/tests/JsonArray/add.cpp @@ -11,8 +11,8 @@ using ArduinoJson::detail::sizeofArray; using ArduinoJson::detail::sizeofString; TEST_CASE("JsonArray::add()") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); JsonArray array = doc.to(); SECTION("int") { @@ -102,49 +102,49 @@ TEST_CASE("JsonArray::add()") { SECTION("should not duplicate const char*") { array.add("world"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } SECTION("should duplicate char*") { array.add(const_cast("world")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("should duplicate std::string") { array.add(std::string("world")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("should duplicate serialized(const char*)") { array.add(serialized("{}")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(2))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(2))); } SECTION("should duplicate serialized(char*)") { array.add(serialized(const_cast("{}"))); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(2))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(2))); } SECTION("should duplicate serialized(std::string)") { array.add(serialized(std::string("{}"))); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(2))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(2))); } SECTION("should duplicate serialized(std::string)") { array.add(serialized(std::string("\0XX", 3))); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(3))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(3))); } } diff --git a/extras/tests/JsonArray/clear.cpp b/extras/tests/JsonArray/clear.cpp index f2da9e36..37cd7594 100644 --- a/extras/tests/JsonArray/clear.cpp +++ b/extras/tests/JsonArray/clear.cpp @@ -26,8 +26,8 @@ TEST_CASE("JsonArray::clear()") { } SECTION("Removed elements are recycled") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); JsonArray array = doc.to(); // fill the pool entirely @@ -39,7 +39,7 @@ TEST_CASE("JsonArray::clear()") { for (int i = 0; i < ARDUINOJSON_POOL_CAPACITY; i++) array.add(i); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } } diff --git a/extras/tests/JsonArray/remove.cpp b/extras/tests/JsonArray/remove.cpp index 556910b9..8baaa88c 100644 --- a/extras/tests/JsonArray/remove.cpp +++ b/extras/tests/JsonArray/remove.cpp @@ -91,8 +91,8 @@ TEST_CASE("JsonArray::remove()") { } TEST_CASE("Removed elements are recycled") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); JsonArray array = doc.to(); // fill the pool entirely @@ -105,7 +105,7 @@ TEST_CASE("Removed elements are recycled") { // add one element; it should use the free slot array.add(42); - REQUIRE(allocator.log() == AllocatorLog() << AllocatorLog::Allocate( - sizeofPool()) // only one pool + REQUIRE(spy.log() == AllocatorLog() << AllocatorLog::Allocate( + sizeofPool()) // only one pool ); } diff --git a/extras/tests/JsonArray/subscript.cpp b/extras/tests/JsonArray/subscript.cpp index 3874e8e3..ec90a8fb 100644 --- a/extras/tests/JsonArray/subscript.cpp +++ b/extras/tests/JsonArray/subscript.cpp @@ -12,8 +12,8 @@ using ArduinoJson::detail::sizeofArray; using ArduinoJson::detail::sizeofString; TEST_CASE("JsonArray::operator[]") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); JsonArray array = doc.to(); SECTION("Pad with null") { @@ -118,22 +118,22 @@ TEST_CASE("JsonArray::operator[]") { SECTION("should not duplicate const char*") { array[0] = "world"; - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } SECTION("should duplicate char*") { array[0] = const_cast("world"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("should duplicate std::string") { array[0] = std::string("world"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("array[0].to()") { diff --git a/extras/tests/JsonDeserializer/array.cpp b/extras/tests/JsonDeserializer/array.cpp index b92502fa..92f44fc3 100644 --- a/extras/tests/JsonDeserializer/array.cpp +++ b/extras/tests/JsonDeserializer/array.cpp @@ -11,8 +11,8 @@ using ArduinoJson::detail::sizeofArray; using ArduinoJson::detail::sizeofString; TEST_CASE("deserialize JSON array") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); SECTION("An empty array") { DeserializationError err = deserializeJson(doc, "[]"); @@ -254,16 +254,16 @@ TEST_CASE("deserialize JSON array") { JsonArray arr = doc.as(); REQUIRE(arr.size() == 0); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Deallocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Deallocate(sizeofPool())); } } TEST_CASE("deserialize JSON array under memory constraints") { TimebombAllocator timebomb(100); - SpyingAllocator allocator(&timebomb); - JsonDocument doc(&allocator); + SpyingAllocator spy(&timebomb); + JsonDocument doc(&spy); SECTION("empty array requires no allocation") { timebomb.setCountdown(0); @@ -307,10 +307,10 @@ TEST_CASE("deserialize JSON array under memory constraints") { SECTION("don't store space characters") { deserializeJson(doc, " [ \"1234567\" ] "); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } } diff --git a/extras/tests/JsonDeserializer/filter.cpp b/extras/tests/JsonDeserializer/filter.cpp index 46b0e4b5..3c847d9f 100644 --- a/extras/tests/JsonDeserializer/filter.cpp +++ b/extras/tests/JsonDeserializer/filter.cpp @@ -691,9 +691,9 @@ TEST_CASE("Filtering") { for (size_t i = 0; i < sizeof(testCases) / sizeof(testCases[0]); i++) { CAPTURE(i); - SpyingAllocator allocator; + SpyingAllocator spy; JsonDocument filter; - JsonDocument doc(&allocator); + JsonDocument doc(&spy); TestCase& tc = testCases[i]; CAPTURE(tc.filter); @@ -708,7 +708,7 @@ TEST_CASE("Filtering") { CHECK(doc.as() == tc.output); doc.shrinkToFit(); - CHECK(allocator.allocatedBytes() == tc.memoryUsage); + CHECK(spy.allocatedBytes() == tc.memoryUsage); } } diff --git a/extras/tests/JsonDeserializer/input_types.cpp b/extras/tests/JsonDeserializer/input_types.cpp index 28f56817..69542ddf 100644 --- a/extras/tests/JsonDeserializer/input_types.cpp +++ b/extras/tests/JsonDeserializer/input_types.cpp @@ -14,8 +14,8 @@ using ArduinoJson::detail::sizeofObject; using ArduinoJson::detail::sizeofString; TEST_CASE("deserializeJson(char*)") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); char input[] = "{\"hello\":\"world\"}"; @@ -23,14 +23,14 @@ TEST_CASE("deserializeJson(char*)") { REQUIRE(err == DeserializationError::Ok); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(5))); } TEST_CASE("deserializeJson(unsigned char*, unsigned int)") { // issue #1897 diff --git a/extras/tests/JsonDeserializer/misc.cpp b/extras/tests/JsonDeserializer/misc.cpp index 036f03a7..950c660c 100644 --- a/extras/tests/JsonDeserializer/misc.cpp +++ b/extras/tests/JsonDeserializer/misc.cpp @@ -12,8 +12,8 @@ using namespace Catch::Matchers; using ArduinoJson::detail::sizeofObject; TEST_CASE("deserializeJson(JsonDocument&)") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); SECTION("Edge cases") { SECTION("null char*") { @@ -117,8 +117,8 @@ TEST_CASE("deserializeJson(JsonDocument&)") { deserializeJson(doc, "{}"); REQUIRE(doc.is()); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Deallocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Deallocate(sizeofPool())); } } diff --git a/extras/tests/JsonDeserializer/object.cpp b/extras/tests/JsonDeserializer/object.cpp index 7bc191ff..199b5c4e 100644 --- a/extras/tests/JsonDeserializer/object.cpp +++ b/extras/tests/JsonDeserializer/object.cpp @@ -11,8 +11,8 @@ using ArduinoJson::detail::sizeofObject; using ArduinoJson::detail::sizeofString; TEST_CASE("deserialize JSON object") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); SECTION("An empty object") { DeserializationError err = deserializeJson(doc, "{}"); @@ -284,7 +284,7 @@ TEST_CASE("deserialize JSON object") { REQUIRE(err == DeserializationError::Ok); REQUIRE(doc.as() == "{\"a\":2}"); - REQUIRE(allocator.log() == + REQUIRE(spy.log() == AllocatorLog() // a << AllocatorLog::Allocate(sizeofString(31)) @@ -331,21 +331,22 @@ TEST_CASE("deserialize JSON object") { REQUIRE(doc.is()); REQUIRE(obj.size() == 0); - REQUIRE(allocator.log() == - AllocatorLog() - // string "hello" - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Reallocate(sizeofString(31), sizeofString(5)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string "world" - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Reallocate(sizeofString(31), sizeofString(5)) - // free pool - << AllocatorLog::Deallocate(sizeofPool()) - // free "hello" and "world" - << AllocatorLog::Deallocate(sizeofString(5)) - << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + // string "hello" + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(5)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string "world" + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(5)) + // free pool + << AllocatorLog::Deallocate(sizeofPool()) + // free "hello" and "world" + << AllocatorLog::Deallocate(sizeofString(5)) + << AllocatorLog::Deallocate(sizeofString(5))); } SECTION("Issue #1335") { @@ -356,11 +357,11 @@ TEST_CASE("deserialize JSON object") { } TEST_CASE("deserialize JSON object under memory constraints") { - TimebombAllocator allocator(1024); - JsonDocument doc(&allocator); + TimebombAllocator timebomb(1024); + JsonDocument doc(&timebomb); SECTION("empty object requires no allocation") { - allocator.setCountdown(0); + timebomb.setCountdown(0); char input[] = "{}"; DeserializationError err = deserializeJson(doc, input); @@ -370,7 +371,7 @@ TEST_CASE("deserialize JSON object under memory constraints") { } SECTION("key allocation fails") { - allocator.setCountdown(0); + timebomb.setCountdown(0); char input[] = "{\"a\":1}"; DeserializationError err = deserializeJson(doc, input); @@ -380,7 +381,7 @@ TEST_CASE("deserialize JSON object under memory constraints") { } SECTION("pool allocation fails") { - allocator.setCountdown(2); + timebomb.setCountdown(2); char input[] = "{\"a\":1}"; DeserializationError err = deserializeJson(doc, input); @@ -390,7 +391,7 @@ TEST_CASE("deserialize JSON object under memory constraints") { } SECTION("string allocation fails") { - allocator.setCountdown(3); + timebomb.setCountdown(3); char input[] = "{\"a\":\"b\"}"; DeserializationError err = deserializeJson(doc, input); diff --git a/extras/tests/JsonDeserializer/string.cpp b/extras/tests/JsonDeserializer/string.cpp index 96ef8b83..2d2d1086 100644 --- a/extras/tests/JsonDeserializer/string.cpp +++ b/extras/tests/JsonDeserializer/string.cpp @@ -99,98 +99,98 @@ TEST_CASE("Invalid JSON string") { } TEST_CASE("Allocation of the key fails") { - TimebombAllocator timebombAllocator(0); - SpyingAllocator spyingAllocator(&timebombAllocator); - JsonDocument doc(&spyingAllocator); + TimebombAllocator timebomb(0); + SpyingAllocator spy(&timebomb); + JsonDocument doc(&spy); SECTION("Quoted string, first member") { REQUIRE(deserializeJson(doc, "{\"example\":1}") == DeserializationError::NoMemory); - REQUIRE(spyingAllocator.log() == - AllocatorLog() << AllocatorLog::AllocateFail(sizeofString(31))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::AllocateFail(sizeofString(31))); } SECTION("Quoted string, second member") { - timebombAllocator.setCountdown(3); + timebomb.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(sizeofPool()) - << AllocatorLog::AllocateFail(sizeofString(31))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::AllocateFail(sizeofString(31))); } SECTION("Non-Quoted string, first member") { REQUIRE(deserializeJson(doc, "{example:1}") == DeserializationError::NoMemory); - REQUIRE(spyingAllocator.log() == - AllocatorLog() << AllocatorLog::AllocateFail(sizeofString(31))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::AllocateFail(sizeofString(31))); } SECTION("Non-Quoted string, second member") { - timebombAllocator.setCountdown(3); + timebomb.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(sizeofPool()) - << AllocatorLog::AllocateFail(sizeofString(31))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::AllocateFail(sizeofString(31))); } } TEST_CASE("String allocation fails") { - SpyingAllocator spyingAllocator(FailingAllocator::instance()); - JsonDocument doc(&spyingAllocator); + SpyingAllocator spy(FailingAllocator::instance()); + JsonDocument doc(&spy); SECTION("Input is const char*") { REQUIRE(deserializeJson(doc, "\"hello\"") == DeserializationError::NoMemory); - REQUIRE(spyingAllocator.log() == - AllocatorLog() << AllocatorLog::AllocateFail(sizeofString(31))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::AllocateFail(sizeofString(31))); } } TEST_CASE("Deduplicate values") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); deserializeJson(doc, "[\"example\",\"example\"]"); CHECK(doc[0].as() == doc[1].as()); - REQUIRE(allocator.log() == AllocatorLog() - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder - << AllocatorLog::Allocate(sizeofString(31)) - // string "example" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // string builder - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Deallocate(sizeofString(31))); + REQUIRE(spy.log() == AllocatorLog() + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder + << AllocatorLog::Allocate(sizeofString(31)) + // string "example" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // string builder + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Deallocate(sizeofString(31))); } TEST_CASE("Deduplicate keys") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); deserializeJson(doc, "[{\"example\":1},{\"example\":2}]"); const char* key1 = doc[0].as().begin()->key().c_str(); const char* key2 = doc[1].as().begin()->key().c_str(); CHECK(key1 == key2); - REQUIRE(allocator.log() == AllocatorLog() - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder - << AllocatorLog::Allocate(sizeofString(31)) - // string "example" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // string builder - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Deallocate(sizeofString(31))); + REQUIRE(spy.log() == AllocatorLog() + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder + << AllocatorLog::Allocate(sizeofString(31)) + // string "example" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // string builder + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Deallocate(sizeofString(31))); } diff --git a/extras/tests/JsonDocument/MemberProxy.cpp b/extras/tests/JsonDocument/MemberProxy.cpp index 6f2d5dea..98c1415e 100644 --- a/extras/tests/JsonDocument/MemberProxy.cpp +++ b/extras/tests/JsonDocument/MemberProxy.cpp @@ -315,8 +315,8 @@ TEST_CASE("MemberProxy::createNestedObject(key)") { } TEST_CASE("Deduplicate keys") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); SECTION("std::string") { doc[0][std::string("example")] = 1; @@ -326,9 +326,9 @@ TEST_CASE("Deduplicate keys") { const char* key2 = doc[1].as().begin()->key().c_str(); CHECK(key1 == key2); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7))); } SECTION("char*") { @@ -340,9 +340,9 @@ TEST_CASE("Deduplicate keys") { const char* key2 = doc[1].as().begin()->key().c_str(); CHECK(key1 == key2); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7))); } SECTION("Arduino String") { @@ -353,9 +353,9 @@ TEST_CASE("Deduplicate keys") { const char* key2 = doc[1].as().begin()->key().c_str(); CHECK(key1 == key2); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7))); } SECTION("Flash string") { @@ -366,9 +366,9 @@ TEST_CASE("Deduplicate keys") { const char* key2 = doc[1].as().begin()->key().c_str(); CHECK(key1 == key2); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7))); } } diff --git a/extras/tests/JsonDocument/add.cpp b/extras/tests/JsonDocument/add.cpp index e8592a9b..577a1a12 100644 --- a/extras/tests/JsonDocument/add.cpp +++ b/extras/tests/JsonDocument/add.cpp @@ -14,23 +14,23 @@ using ArduinoJson::detail::sizeofArray; using ArduinoJson::detail::sizeofString; TEST_CASE("JsonDocument::add()") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); SECTION("integer") { doc.add(42); REQUIRE(doc.as() == "[42]"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } SECTION("const char*") { doc.add("hello"); REQUIRE(doc.as() == "[\"hello\"]"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } SECTION("std::string") { @@ -38,9 +38,9 @@ TEST_CASE("JsonDocument::add()") { doc.add(std::string("example")); CHECK(doc[0].as() == doc[1].as()); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7))); } SECTION("char*") { @@ -49,9 +49,9 @@ TEST_CASE("JsonDocument::add()") { doc.add(value); CHECK(doc[0].as() == doc[1].as()); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7))); } SECTION("Arduino String") { @@ -59,9 +59,9 @@ TEST_CASE("JsonDocument::add()") { doc.add(String("example")); CHECK(doc[0].as() == doc[1].as()); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7))); } SECTION("Flash string") { @@ -69,8 +69,8 @@ TEST_CASE("JsonDocument::add()") { doc.add(F("example")); CHECK(doc[0].as() == doc[1].as()); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(7))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(7))); } } diff --git a/extras/tests/JsonDocument/overflowed.cpp b/extras/tests/JsonDocument/overflowed.cpp index 9267881e..25fb03a6 100644 --- a/extras/tests/JsonDocument/overflowed.cpp +++ b/extras/tests/JsonDocument/overflowed.cpp @@ -8,75 +8,75 @@ #include "Allocators.hpp" TEST_CASE("JsonDocument::overflowed()") { - TimebombAllocator allocator(10); - JsonDocument doc(&allocator); + TimebombAllocator timebomb(10); + JsonDocument doc(&timebomb); SECTION("returns false on a fresh object") { - allocator.setCountdown(0); + timebomb.setCountdown(0); CHECK(doc.overflowed() == false); } SECTION("returns true after a failed insertion") { - allocator.setCountdown(0); + timebomb.setCountdown(0); doc.add(0); CHECK(doc.overflowed() == true); } SECTION("returns false after successful insertion") { - allocator.setCountdown(2); + timebomb.setCountdown(2); doc.add(0); CHECK(doc.overflowed() == false); } SECTION("returns true after a failed string copy") { - allocator.setCountdown(0); + timebomb.setCountdown(0); doc.add(std::string("example")); CHECK(doc.overflowed() == true); } SECTION("returns false after a successful string copy") { - allocator.setCountdown(3); + timebomb.setCountdown(3); doc.add(std::string("example")); CHECK(doc.overflowed() == false); } SECTION("returns true after a failed member add") { - allocator.setCountdown(0); + timebomb.setCountdown(0); doc["example"] = true; CHECK(doc.overflowed() == true); } SECTION("returns true after a failed deserialization") { - allocator.setCountdown(0); + timebomb.setCountdown(0); deserializeJson(doc, "[1, 2]"); CHECK(doc.overflowed() == true); } SECTION("returns false after a successful deserialization") { - allocator.setCountdown(3); + timebomb.setCountdown(3); deserializeJson(doc, "[\"example\"]"); CHECK(doc.overflowed() == false); } SECTION("returns false after clear()") { - allocator.setCountdown(0); + timebomb.setCountdown(0); doc.add(0); doc.clear(); CHECK(doc.overflowed() == false); } SECTION("remains false after shrinkToFit()") { - allocator.setCountdown(2); + timebomb.setCountdown(2); doc.add(0); - allocator.setCountdown(2); + timebomb.setCountdown(2); doc.shrinkToFit(); CHECK(doc.overflowed() == false); } SECTION("remains true after shrinkToFit()") { - allocator.setCountdown(0); + timebomb.setCountdown(0); doc.add(0); - allocator.setCountdown(2); + timebomb.setCountdown(2); doc.shrinkToFit(); CHECK(doc.overflowed() == true); } diff --git a/extras/tests/JsonObject/copy.cpp b/extras/tests/JsonObject/copy.cpp index 8a6b2a37..795de4a1 100644 --- a/extras/tests/JsonObject/copy.cpp +++ b/extras/tests/JsonObject/copy.cpp @@ -10,77 +10,77 @@ using ArduinoJson::detail::sizeofString; TEST_CASE("JsonObject::set()") { - SpyingAllocator allocator; - JsonDocument doc1(&allocator); - JsonDocument doc2(&allocator); + SpyingAllocator spy; + JsonDocument doc1(&spy); + JsonDocument doc2(&spy); JsonObject obj1 = doc1.to(); JsonObject obj2 = doc2.to(); SECTION("doesn't copy static string in key or value") { obj1["hello"] = "world"; - allocator.clearLog(); + spy.clearLog(); bool success = obj2.set(obj1); REQUIRE(success == true); REQUIRE(obj2["hello"] == std::string("world")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } SECTION("copy local string value") { obj1["hello"] = std::string("world"); - allocator.clearLog(); + spy.clearLog(); bool success = obj2.set(obj1); REQUIRE(success == true); REQUIRE(obj2["hello"] == std::string("world")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("copy local key") { obj1[std::string("hello")] = "world"; - allocator.clearLog(); + spy.clearLog(); bool success = obj2.set(obj1); REQUIRE(success == true); REQUIRE(obj2["hello"] == std::string("world")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool())); } SECTION("copy string from deserializeJson()") { deserializeJson(doc1, "{'hello':'world'}"); - allocator.clearLog(); + spy.clearLog(); bool success = obj2.set(obj1); REQUIRE(success == true); REQUIRE(obj2["hello"] == std::string("world")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("copy string from deserializeMsgPack()") { deserializeMsgPack(doc1, "\x81\xA5hello\xA5world"); - allocator.clearLog(); + spy.clearLog(); bool success = obj2.set(obj1); REQUIRE(success == true); REQUIRE(obj2["hello"] == std::string("world")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("should work with JsonObjectConst") { diff --git a/extras/tests/JsonObject/subscript.cpp b/extras/tests/JsonObject/subscript.cpp index d286d957..963f8969 100644 --- a/extras/tests/JsonObject/subscript.cpp +++ b/extras/tests/JsonObject/subscript.cpp @@ -11,8 +11,8 @@ using ArduinoJson::detail::sizeofObject; using ArduinoJson::detail::sizeofString; TEST_CASE("JsonObject::operator[]") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); JsonObject obj = doc.to(); SECTION("int") { @@ -106,65 +106,65 @@ TEST_CASE("JsonObject::operator[]") { SECTION("should not duplicate const char*") { obj["hello"] = "world"; - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } SECTION("should duplicate char* value") { obj["hello"] = const_cast("world"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("should duplicate char* key") { obj[const_cast("hello")] = "world"; - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool())); } SECTION("should duplicate char* key&value") { obj[const_cast("hello")] = const_cast("world"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("should duplicate std::string value") { obj["hello"] = std::string("world"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("should duplicate std::string key") { obj[std::string("hello")] = "world"; - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool())); } SECTION("should duplicate std::string key&value") { obj[std::string("hello")] = std::string("world"); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(5))); } SECTION("should duplicate a non-static JsonString key") { obj[JsonString("hello", JsonString::Copied)] = "world"; - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofPool())); } SECTION("should not duplicate a static JsonString key") { obj[JsonString("hello", JsonString::Linked)] = "world"; - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } SECTION("should ignore null key") { diff --git a/extras/tests/JsonVariant/clear.cpp b/extras/tests/JsonVariant/clear.cpp index 3a4a6423..b40dd7de 100644 --- a/extras/tests/JsonVariant/clear.cpp +++ b/extras/tests/JsonVariant/clear.cpp @@ -11,8 +11,8 @@ using ArduinoJson::detail::sizeofString; TEST_CASE("JsonVariant::clear()") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); JsonVariant var = doc.to(); SECTION("size goes back to zero") { @@ -33,8 +33,8 @@ TEST_CASE("JsonVariant::clear()") { var.set(std::string("hello")); var.clear(); - REQUIRE(allocator.log() == - AllocatorLog() << AllocatorLog::Allocate(sizeofString(5)) - << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(5)) + << AllocatorLog::Deallocate(sizeofString(5))); } } diff --git a/extras/tests/JsonVariant/remove.cpp b/extras/tests/JsonVariant/remove.cpp index e2d52c54..830ed6aa 100644 --- a/extras/tests/JsonVariant/remove.cpp +++ b/extras/tests/JsonVariant/remove.cpp @@ -12,8 +12,8 @@ using ArduinoJson::detail::sizeofArray; using ArduinoJson::detail::sizeofString; TEST_CASE("JsonVariant::remove(int)") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); SECTION("release top level strings") { doc.add(std::string("hello")); @@ -23,22 +23,22 @@ TEST_CASE("JsonVariant::remove(int)") { JsonVariant var = doc.as(); REQUIRE(var.as() == "[\"hello\",\"hello\",\"world\"]"); - allocator.clearLog(); + spy.clearLog(); var.remove(1); REQUIRE(var.as() == "[\"hello\",\"world\"]"); - REQUIRE(allocator.log() == AllocatorLog()); + REQUIRE(spy.log() == AllocatorLog()); - allocator.clearLog(); + spy.clearLog(); var.remove(1); REQUIRE(var.as() == "[\"hello\"]"); - REQUIRE(allocator.log() == - AllocatorLog() << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Deallocate(sizeofString(5))); - allocator.clearLog(); + spy.clearLog(); var.remove(0); REQUIRE(var.as() == "[]"); - REQUIRE(allocator.log() == - AllocatorLog() << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Deallocate(sizeofString(5))); } SECTION("release strings in nested array") { @@ -47,12 +47,12 @@ TEST_CASE("JsonVariant::remove(int)") { JsonVariant var = doc.as(); REQUIRE(var.as() == "[[\"hello\"]]"); - allocator.clearLog(); + spy.clearLog(); var.remove(0); REQUIRE(var.as() == "[]"); - REQUIRE(allocator.log() == - AllocatorLog() << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Deallocate(sizeofString(5))); } } diff --git a/extras/tests/JsonVariant/set.cpp b/extras/tests/JsonVariant/set.cpp index e9e28641..72381c92 100644 --- a/extras/tests/JsonVariant/set.cpp +++ b/extras/tests/JsonVariant/set.cpp @@ -177,41 +177,41 @@ TEST_CASE("JsonVariant::set(JsonDocument)") { } TEST_CASE("JsonVariant::set() releases the previous value") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); doc["hello"] = std::string("world"); - allocator.clearLog(); + spy.clearLog(); JsonVariant v = doc["hello"]; SECTION("int") { v.set(42); - REQUIRE(allocator.log() == - AllocatorLog() << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Deallocate(sizeofString(5))); } SECTION("bool") { v.set(false); - REQUIRE(allocator.log() == - AllocatorLog() << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Deallocate(sizeofString(5))); } SECTION("const char*") { v.set("hello"); - REQUIRE(allocator.log() == - AllocatorLog() << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Deallocate(sizeofString(5))); } SECTION("float") { v.set(1.2); - REQUIRE(allocator.log() == - AllocatorLog() << AllocatorLog::Deallocate(sizeofString(5))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Deallocate(sizeofString(5))); } SECTION("Serialized") { v.set(serialized("[]")); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Deallocate(sizeofString(5)) - << AllocatorLog::Allocate(sizeofString(2))); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Deallocate(sizeofString(5)) + << AllocatorLog::Allocate(sizeofString(2))); } } diff --git a/extras/tests/Misc/printable.cpp b/extras/tests/Misc/printable.cpp index 07b6763f..6b66c10f 100644 --- a/extras/tests/Misc/printable.cpp +++ b/extras/tests/Misc/printable.cpp @@ -53,8 +53,8 @@ struct PrintableString : public Printable { TEST_CASE("Printable") { SECTION("Doesn't overflow") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); const char* value = "example"; doc.set(666); // to make sure we override the value @@ -65,10 +65,10 @@ TEST_CASE("Printable") { CHECK(doc.as() == value); CHECK(printable.totalBytesWritten() == 7); CHECK(doc.overflowed() == false); - CHECK(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("Via Print::write(const char* size_t)") { @@ -77,16 +77,16 @@ TEST_CASE("Printable") { CHECK(doc.as() == value); CHECK(printable.totalBytesWritten() == 7); CHECK(doc.overflowed() == false); - CHECK(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } } SECTION("First allocation fails") { - SpyingAllocator spyingAllocator(FailingAllocator::instance()); - JsonDocument doc(&spyingAllocator); + SpyingAllocator spy(FailingAllocator::instance()); + JsonDocument doc(&spy); const char* value = "hello world"; doc.set(666); // to make sure we override the value @@ -100,8 +100,8 @@ TEST_CASE("Printable") { CHECK(doc.isNull()); CHECK(printable.totalBytesWritten() == 0); CHECK(doc.overflowed() == true); - CHECK(spyingAllocator.log() == - AllocatorLog() << AllocatorLog::AllocateFail(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::AllocateFail(sizeofString(31))); } SECTION("Via Print::write(const char*, size_t)") { @@ -113,15 +113,15 @@ TEST_CASE("Printable") { CHECK(doc.isNull()); CHECK(printable.totalBytesWritten() == 0); CHECK(doc.overflowed() == true); - CHECK(spyingAllocator.log() == - AllocatorLog() << AllocatorLog::AllocateFail(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::AllocateFail(sizeofString(31))); } } SECTION("Reallocation fails") { - TimebombAllocator timebombAllocator(1); - SpyingAllocator spyingAllocator(&timebombAllocator); - JsonDocument doc(&spyingAllocator); + TimebombAllocator timebomb(1); + SpyingAllocator spy(&timebomb); + JsonDocument doc(&spy); const char* value = "Lorem ipsum dolor sit amet, cons"; // > 31 chars doc.set(666); // to make sure we override the value @@ -135,11 +135,11 @@ TEST_CASE("Printable") { CHECK(doc.isNull()); CHECK(printable.totalBytesWritten() == 31); CHECK(doc.overflowed() == true); - CHECK(spyingAllocator.log() == - AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::ReallocateFail(sizeofString(31), - sizeofString(63)) - << AllocatorLog::Deallocate(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::ReallocateFail(sizeofString(31), + sizeofString(63)) + << AllocatorLog::Deallocate(sizeofString(31))); } SECTION("Via Print::write(const char*, size_t)") { @@ -151,11 +151,11 @@ TEST_CASE("Printable") { CHECK(doc.isNull()); CHECK(printable.totalBytesWritten() == 31); CHECK(doc.overflowed() == true); - CHECK(spyingAllocator.log() == - AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::ReallocateFail(sizeofString(31), - sizeofString(63)) - << AllocatorLog::Deallocate(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::ReallocateFail(sizeofString(31), + sizeofString(63)) + << AllocatorLog::Deallocate(sizeofString(31))); } } @@ -168,19 +168,19 @@ TEST_CASE("Printable") { } SECTION("String deduplication") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); doc.add(PrintableString("Hello World!")); doc.add(PrintableString("Hello World!")); REQUIRE(doc.size() == 2); CHECK(doc[0] == "Hello World!"); CHECK(doc[1] == "Hello World!"); - CHECK(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(12)) - << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Deallocate(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(12)) + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Deallocate(sizeofString(31))); } } diff --git a/extras/tests/MsgPackDeserializer/deserializeVariant.cpp b/extras/tests/MsgPackDeserializer/deserializeVariant.cpp index eb04eab7..9ebe8af2 100644 --- a/extras/tests/MsgPackDeserializer/deserializeVariant.cpp +++ b/extras/tests/MsgPackDeserializer/deserializeVariant.cpp @@ -20,8 +20,8 @@ static void checkValue(const char* input, T expected) { static void checkError(size_t timebombCountDown, const char* input, DeserializationError expected) { - TimebombAllocator timebombAllocator(timebombCountDown); - JsonDocument doc(&timebombAllocator); + TimebombAllocator timebomb(timebombCountDown); + JsonDocument doc(&timebomb); DeserializationError error = deserializeMsgPack(doc, input); diff --git a/extras/tests/MsgPackDeserializer/filter.cpp b/extras/tests/MsgPackDeserializer/filter.cpp index 7efb7d35..92af5d16 100644 --- a/extras/tests/MsgPackDeserializer/filter.cpp +++ b/extras/tests/MsgPackDeserializer/filter.cpp @@ -12,8 +12,8 @@ using namespace ArduinoJson::detail; TEST_CASE("deserializeMsgPack() filter") { - SpyingAllocator allocator; - JsonDocument doc(&allocator); + SpyingAllocator spy; + JsonDocument doc(&spy); DeserializationError error; JsonDocument filter; @@ -29,9 +29,9 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::IncompleteInput); CHECK(doc.as() == "{}"); - CHECK(allocator.log() == - AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Deallocate(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Deallocate(sizeofString(31))); } SECTION("input truncated after inside skipped uint 8") { @@ -40,9 +40,9 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::IncompleteInput); CHECK(doc.as() == "{}"); - CHECK(allocator.log() == - AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Deallocate(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Deallocate(sizeofString(31))); } SECTION("input truncated after before skipped string size") { @@ -50,9 +50,9 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::IncompleteInput); CHECK(doc.as() == "{}"); - CHECK(allocator.log() == - AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Deallocate(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Deallocate(sizeofString(31))); } SECTION("input truncated after before skipped ext size") { @@ -60,9 +60,9 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::IncompleteInput); CHECK(doc.as() == "{}"); - CHECK(allocator.log() == - AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Deallocate(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Deallocate(sizeofString(31))); } SECTION("skip nil") { @@ -71,7 +71,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -83,9 +83,9 @@ TEST_CASE("deserializeMsgPack() filter") { filterOpt); CHECK(error == DeserializationError::InvalidInput); - CHECK(allocator.log() == - AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) - << AllocatorLog::Deallocate(sizeofString(31))); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofString(31)) + << AllocatorLog::Deallocate(sizeofString(31))); } SECTION("skip false") { @@ -94,7 +94,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -107,7 +107,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -120,7 +120,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -133,7 +133,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -146,7 +146,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -159,7 +159,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -172,7 +172,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -185,7 +185,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -199,7 +199,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -213,7 +213,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -228,7 +228,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -243,7 +243,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -257,7 +257,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -272,7 +272,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -285,7 +285,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -298,7 +298,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -311,7 +311,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -325,7 +325,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -338,7 +338,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -351,7 +351,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -365,7 +365,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -378,7 +378,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -392,7 +392,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -409,7 +409,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -423,7 +423,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -439,7 +439,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -457,7 +457,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -473,7 +473,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -489,7 +489,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -505,7 +505,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -521,7 +521,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -539,7 +539,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -555,7 +555,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -571,7 +571,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -587,7 +587,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() << AllocatorLog::Allocate(sizeofString(31)) << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7)) @@ -612,7 +612,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -629,7 +629,7 @@ TEST_CASE("deserializeMsgPack() filter") { // string "include" << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7))); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -660,7 +660,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -691,7 +691,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -716,7 +716,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -729,7 +729,7 @@ TEST_CASE("deserializeMsgPack() filter") { // string "include" << AllocatorLog::Reallocate(sizeofString(31), sizeofString(7))); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -750,7 +750,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -771,7 +771,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -792,7 +792,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -813,7 +813,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -834,7 +834,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -855,7 +855,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -877,7 +877,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -900,7 +900,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -921,7 +921,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -942,7 +942,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -964,7 +964,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -987,7 +987,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1009,7 +1009,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1032,7 +1032,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1053,7 +1053,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1087,7 +1087,7 @@ TEST_CASE("deserializeMsgPack() filter") { doc, "\x82\xA7onlyarr\xdb\x00\x00\x00\x05hello\xA7include\x2A", filterOpt); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1109,7 +1109,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1133,7 +1133,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1159,7 +1159,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyarr\":null,\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1186,7 +1186,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "[]"); - CHECK(allocator.log() == AllocatorLog()); + CHECK(spy.log() == AllocatorLog()); } } @@ -1199,8 +1199,8 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "[1,2,3]"); - CHECK(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool())); + CHECK(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool())); } } } @@ -1221,7 +1221,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":{\"measure\":2},\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1249,7 +1249,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":{\"measure\":2},\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1278,7 +1278,7 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":{\"measure\":2},\"include\":42}"); - CHECK(allocator.log() == + CHECK(spy.log() == AllocatorLog() // string builder's buffer << AllocatorLog::Allocate(sizeofString(31)) @@ -1302,19 +1302,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip false") { @@ -1323,19 +1323,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip true") { @@ -1344,19 +1344,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip positive fixint") { @@ -1365,19 +1365,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip negative fixint") { @@ -1386,19 +1386,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip uint 8") { @@ -1407,19 +1407,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip uint 16") { @@ -1428,19 +1428,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip uint 32") { @@ -1449,19 +1449,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip uint 64") { @@ -1472,19 +1472,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip int 8") { @@ -1493,19 +1493,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip int 16") { @@ -1514,19 +1514,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip int 32") { @@ -1535,19 +1535,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip int 64") { @@ -1558,19 +1558,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip float 32") { @@ -1579,19 +1579,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip float 64") { @@ -1602,19 +1602,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip fixstr") { @@ -1623,19 +1623,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip str 8") { @@ -1657,19 +1657,19 @@ TEST_CASE("deserializeMsgPack() filter") { doc, "\x82\xA7onlyobj\xdb\x00\x00\x00\x05hello\xA7include\x2A", filterOpt); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip fixarray") { @@ -1678,19 +1678,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip array 16") { @@ -1701,19 +1701,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } SECTION("skip array 32") { @@ -1725,19 +1725,19 @@ TEST_CASE("deserializeMsgPack() filter") { CHECK(error == DeserializationError::Ok); CHECK(doc.as() == "{\"onlyobj\":null,\"include\":42}"); - CHECK(allocator.log() == AllocatorLog() - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "onlyarr" - << AllocatorLog::Reallocate(sizeofString(31), - sizeofString(7)) - // pool - << AllocatorLog::Allocate(sizeofPool()) - // string builder's buffer - << AllocatorLog::Allocate(sizeofString(31)) - // string "include" - << AllocatorLog::Reallocate( - sizeofString(31), sizeofString(7))); + CHECK(spy.log() == AllocatorLog() + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "onlyarr" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7)) + // pool + << AllocatorLog::Allocate(sizeofPool()) + // string builder's buffer + << AllocatorLog::Allocate(sizeofString(31)) + // string "include" + << AllocatorLog::Reallocate(sizeofString(31), + sizeofString(7))); } } diff --git a/extras/tests/ResourceManager/shrinkToFit.cpp b/extras/tests/ResourceManager/shrinkToFit.cpp index 17eb6029..ed90237c 100644 --- a/extras/tests/ResourceManager/shrinkToFit.cpp +++ b/extras/tests/ResourceManager/shrinkToFit.cpp @@ -11,8 +11,7 @@ using namespace ArduinoJson::detail; TEST_CASE("ResourceManager::shrinkToFit()") { - TimebombAllocator allocator(100); - SpyingAllocator spyingAllocator(&allocator); + SpyingAllocator spyingAllocator; ResourceManager resources(&spyingAllocator); SECTION("empty") { diff --git a/extras/tests/ResourceManager/size.cpp b/extras/tests/ResourceManager/size.cpp index 96815d01..e4319648 100644 --- a/extras/tests/ResourceManager/size.cpp +++ b/extras/tests/ResourceManager/size.cpp @@ -11,15 +11,15 @@ using namespace ArduinoJson::detail; TEST_CASE("ResourceManager::size()") { - TimebombAllocator allocator(0); - ResourceManager resources(&allocator); + TimebombAllocator timebomb(0); + ResourceManager resources(&timebomb); SECTION("Initial size is 0") { REQUIRE(0 == resources.size()); } SECTION("Doesn't grow when allocation of second pool fails") { - allocator.setCountdown(1); + timebomb.setCountdown(1); for (size_t i = 0; i < ARDUINOJSON_POOL_CAPACITY; i++) resources.allocSlot(); size_t size = resources.size(); diff --git a/extras/tests/ResourceManager/swap.cpp b/extras/tests/ResourceManager/swap.cpp index bfbc99f4..311f0580 100644 --- a/extras/tests/ResourceManager/swap.cpp +++ b/extras/tests/ResourceManager/swap.cpp @@ -19,9 +19,9 @@ static void fullPreallocatedPools(ResourceManager& resources) { TEST_CASE("ResourceManager::swap()") { SECTION("Both using preallocated pool list") { - SpyingAllocator allocator; - ResourceManager a(&allocator); - ResourceManager b(&allocator); + SpyingAllocator spy; + ResourceManager a(&spy); + ResourceManager b(&spy); auto a1 = a.allocSlot(); auto b1 = b.allocSlot(); @@ -31,14 +31,14 @@ TEST_CASE("ResourceManager::swap()") { REQUIRE(a1->data() == b.getSlot(a1.id())->data()); REQUIRE(b1->data() == a.getSlot(b1.id())->data()); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) * 2); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) * 2); } SECTION("Only left using preallocated pool list") { - SpyingAllocator allocator; - ResourceManager a(&allocator); - ResourceManager b(&allocator); + SpyingAllocator spy; + ResourceManager a(&spy); + ResourceManager b(&spy); fullPreallocatedPools(b); auto a1 = a.allocSlot(); @@ -48,19 +48,19 @@ TEST_CASE("ResourceManager::swap()") { REQUIRE(a1->data() == b.getSlot(a1.id())->data()); REQUIRE(b1->data() == a.getSlot(b1.id())->data()); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) * - (ARDUINOJSON_INITIAL_POOL_COUNT + 1) - << AllocatorLog::Allocate(sizeofPoolList( - ARDUINOJSON_INITIAL_POOL_COUNT * 2)) - << AllocatorLog::Allocate(sizeofPool())); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) * + (ARDUINOJSON_INITIAL_POOL_COUNT + 1) + << AllocatorLog::Allocate(sizeofPoolList( + ARDUINOJSON_INITIAL_POOL_COUNT * 2)) + << AllocatorLog::Allocate(sizeofPool())); } SECTION("Only right using preallocated pool list") { - SpyingAllocator allocator; - ResourceManager a(&allocator); + SpyingAllocator spy; + ResourceManager a(&spy); fullPreallocatedPools(a); - ResourceManager b(&allocator); + ResourceManager b(&spy); auto a1 = a.allocSlot(); auto b1 = b.allocSlot(); @@ -69,19 +69,19 @@ TEST_CASE("ResourceManager::swap()") { REQUIRE(a1->data() == b.getSlot(a1.id())->data()); REQUIRE(b1->data() == a.getSlot(b1.id())->data()); - REQUIRE(allocator.log() == AllocatorLog() - << AllocatorLog::Allocate(sizeofPool()) * - ARDUINOJSON_INITIAL_POOL_COUNT - << AllocatorLog::Allocate(sizeofPoolList( - ARDUINOJSON_INITIAL_POOL_COUNT * 2)) - << AllocatorLog::Allocate(sizeofPool()) * 2); + REQUIRE(spy.log() == AllocatorLog() + << AllocatorLog::Allocate(sizeofPool()) * + ARDUINOJSON_INITIAL_POOL_COUNT + << AllocatorLog::Allocate(sizeofPoolList( + ARDUINOJSON_INITIAL_POOL_COUNT * 2)) + << AllocatorLog::Allocate(sizeofPool()) * 2); } SECTION("None is using preallocated pool list") { - SpyingAllocator allocator; - ResourceManager a(&allocator); + SpyingAllocator spy; + ResourceManager a(&spy); fullPreallocatedPools(a); - ResourceManager b(&allocator); + ResourceManager b(&spy); fullPreallocatedPools(b); auto a1 = a.allocSlot();