Tests: use a consistent naming convention for allocators

This commit is contained in:
Benoit Blanchon
2023-07-25 14:53:54 +02:00
parent 7a76da3bc7
commit 30ec507989
25 changed files with 698 additions and 698 deletions

View File

@@ -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<JsonVariant>();
SECTION("deserializeJson()") {
@@ -63,7 +63,7 @@ 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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7))
<< AllocatorLog::Allocate(sizeofString(12)));

View File

@@ -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<JsonArray>();
SECTION("int") {
@@ -102,48 +102,48 @@ TEST_CASE("JsonArray::add()") {
SECTION("should not duplicate const char*") {
array.add("world");
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()));
}
SECTION("should duplicate char*") {
array.add(const_cast<char*>("world"));
REQUIRE(allocator.log() == AllocatorLog()
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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(5)));
}
SECTION("should duplicate serialized(const char*)") {
array.add(serialized("{}"));
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(2)));
}
SECTION("should duplicate serialized(char*)") {
array.add(serialized(const_cast<char*>("{}")));
REQUIRE(allocator.log() == AllocatorLog()
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()
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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(3)));
}

View File

@@ -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<JsonArray>();
// 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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()));
}
}

View File

@@ -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<JsonArray>();
// 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(
REQUIRE(spy.log() == AllocatorLog() << AllocatorLog::Allocate(
sizeofPool()) // only one pool
);
}

View File

@@ -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<JsonArray>();
SECTION("Pad with null") {
@@ -118,20 +118,20 @@ TEST_CASE("JsonArray::operator[]") {
SECTION("should not duplicate const char*") {
array[0] = "world";
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()));
}
SECTION("should duplicate char*") {
array[0] = const_cast<char*>("world");
REQUIRE(allocator.log() == AllocatorLog()
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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(5)));
}

View File

@@ -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,7 +254,7 @@ TEST_CASE("deserialize JSON array") {
JsonArray arr = doc.as<JsonArray>();
REQUIRE(arr.size() == 0);
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Deallocate(sizeofPool()));
}
@@ -262,8 +262,8 @@ TEST_CASE("deserialize JSON array") {
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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
}

View File

@@ -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<std::string>() == tc.output);
doc.shrinkToFit();
CHECK(allocator.allocatedBytes() == tc.memoryUsage);
CHECK(spy.allocatedBytes() == tc.memoryUsage);
}
}

View File

@@ -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,7 +23,7 @@ TEST_CASE("deserializeJson(char*)") {
REQUIRE(err == DeserializationError::Ok);
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(5))

View File

@@ -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,7 +117,7 @@ TEST_CASE("deserializeJson(JsonDocument&)") {
deserializeJson(doc, "{}");
REQUIRE(doc.is<JsonObject>());
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Deallocate(sizeofPool()));
}

View File

@@ -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<std::string>() == "{\"a\":2}");
REQUIRE(allocator.log() ==
REQUIRE(spy.log() ==
AllocatorLog()
// a
<< AllocatorLog::Allocate(sizeofString(31))
@@ -331,16 +331,17 @@ TEST_CASE("deserialize JSON object") {
REQUIRE(doc.is<JsonObject>());
REQUIRE(obj.size() == 0);
REQUIRE(allocator.log() ==
AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
// string "hello"
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(sizeofString(31), sizeofString(5))
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(5))
// pool
<< AllocatorLog::Allocate(sizeofPool())
// string "world"
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(sizeofString(31), sizeofString(5))
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(5))
// free pool
<< AllocatorLog::Deallocate(sizeofPool())
// free "hello" and "world"
@@ -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);

View File

@@ -99,23 +99,23 @@ 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))
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(5))
<< AllocatorLog::Allocate(sizeofPool())
@@ -125,16 +125,16 @@ TEST_CASE("Allocation of the key fails") {
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))
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(5))
<< AllocatorLog::Allocate(sizeofPool())
@@ -143,24 +143,24 @@ TEST_CASE("Allocation of the key fails") {
}
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<const char*>() == doc[1].as<const char*>());
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
// pool
<< AllocatorLog::Allocate(sizeofPool())
// string builder
@@ -174,15 +174,15 @@ TEST_CASE("Deduplicate values") {
}
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<JsonObject>().begin()->key().c_str();
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
CHECK(key1 == key2);
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
// pool
<< AllocatorLog::Allocate(sizeofPool())
// string builder

View File

@@ -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,7 +326,7 @@ TEST_CASE("Deduplicate keys") {
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
CHECK(key1 == key2);
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7)));
}
@@ -340,7 +340,7 @@ TEST_CASE("Deduplicate keys") {
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
CHECK(key1 == key2);
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7)));
}
@@ -353,7 +353,7 @@ TEST_CASE("Deduplicate keys") {
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
CHECK(key1 == key2);
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7)));
}
@@ -366,7 +366,7 @@ TEST_CASE("Deduplicate keys") {
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
CHECK(key1 == key2);
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7)));
}

View File

@@ -14,14 +14,14 @@ 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<std::string>() == "[42]");
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()));
}
@@ -29,7 +29,7 @@ TEST_CASE("JsonDocument::add()") {
doc.add("hello");
REQUIRE(doc.as<std::string>() == "[\"hello\"]");
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()));
}
@@ -38,7 +38,7 @@ TEST_CASE("JsonDocument::add()") {
doc.add(std::string("example"));
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7)));
}
@@ -49,7 +49,7 @@ TEST_CASE("JsonDocument::add()") {
doc.add(value);
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7)));
}
@@ -59,7 +59,7 @@ TEST_CASE("JsonDocument::add()") {
doc.add(String("example"));
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7)));
}
@@ -69,7 +69,7 @@ TEST_CASE("JsonDocument::add()") {
doc.add(F("example"));
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(7)));
}

View File

@@ -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);
}

View File

@@ -10,60 +10,60 @@
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>();
JsonObject obj2 = doc2.to<JsonObject>();
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()
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()
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()
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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(5))
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(5)));
@@ -71,13 +71,13 @@ TEST_CASE("JsonObject::set()") {
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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(5))
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(5)));

View File

@@ -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<JsonObject>();
SECTION("int") {
@@ -106,27 +106,27 @@ TEST_CASE("JsonObject::operator[]") {
SECTION("should not duplicate const char*") {
obj["hello"] = "world";
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()));
}
SECTION("should duplicate char* value") {
obj["hello"] = const_cast<char*>("world");
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(5)));
}
SECTION("should duplicate char* key") {
obj[const_cast<char*>("hello")] = "world";
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(5))
<< AllocatorLog::Allocate(sizeofPool()));
}
SECTION("should duplicate char* key&value") {
obj[const_cast<char*>("hello")] = const_cast<char*>("world");
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(5))
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(5)));
@@ -134,21 +134,21 @@ TEST_CASE("JsonObject::operator[]") {
SECTION("should duplicate std::string value") {
obj["hello"] = std::string("world");
REQUIRE(allocator.log() == AllocatorLog()
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()
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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(5))
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(5)));
@@ -156,14 +156,14 @@ TEST_CASE("JsonObject::operator[]") {
SECTION("should duplicate a non-static JsonString key") {
obj[JsonString("hello", JsonString::Copied)] = "world";
REQUIRE(allocator.log() == AllocatorLog()
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()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()));
}

View File

@@ -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<JsonVariant>();
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))
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(5))
<< AllocatorLog::Deallocate(sizeofString(5)));
}
}

View File

@@ -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<JsonVariant>();
REQUIRE(var.as<std::string>() == "[\"hello\",\"hello\",\"world\"]");
allocator.clearLog();
spy.clearLog();
var.remove(1);
REQUIRE(var.as<std::string>() == "[\"hello\",\"world\"]");
REQUIRE(allocator.log() == AllocatorLog());
REQUIRE(spy.log() == AllocatorLog());
allocator.clearLog();
spy.clearLog();
var.remove(1);
REQUIRE(var.as<std::string>() == "[\"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<std::string>() == "[]");
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<JsonVariant>();
REQUIRE(var.as<std::string>() == "[[\"hello\"]]");
allocator.clearLog();
spy.clearLog();
var.remove(0);
REQUIRE(var.as<std::string>() == "[]");
REQUIRE(allocator.log() ==
AllocatorLog() << AllocatorLog::Deallocate(sizeofString(5)));
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Deallocate(sizeofString(5)));
}
}

View File

@@ -177,40 +177,40 @@ 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<const char*>") {
v.set(serialized("[]"));
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Deallocate(sizeofString(5))
<< AllocatorLog::Allocate(sizeofString(2)));
}

View File

@@ -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<std::string>() == value);
CHECK(printable.totalBytesWritten() == 7);
CHECK(doc.overflowed() == false);
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("Via Print::write(const char* size_t)") {
@@ -77,16 +77,16 @@ TEST_CASE("Printable") {
CHECK(doc.as<std::string>() == value);
CHECK(printable.totalBytesWritten() == 7);
CHECK(doc.overflowed() == false);
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< 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,8 +135,8 @@ TEST_CASE("Printable") {
CHECK(doc.isNull());
CHECK(printable.totalBytesWritten() == 31);
CHECK(doc.overflowed() == true);
CHECK(spyingAllocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::ReallocateFail(sizeofString(31),
sizeofString(63))
<< AllocatorLog::Deallocate(sizeofString(31)));
@@ -151,8 +151,8 @@ TEST_CASE("Printable") {
CHECK(doc.isNull());
CHECK(printable.totalBytesWritten() == 31);
CHECK(doc.overflowed() == true);
CHECK(spyingAllocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::ReallocateFail(sizeofString(31),
sizeofString(63))
<< AllocatorLog::Deallocate(sizeofString(31)));
@@ -168,14 +168,14 @@ TEST_CASE("Printable") {
}
SECTION("String deduplication") {
SpyingAllocator allocator;
JsonDocument doc(&allocator);
SpyingAllocator spy;
JsonDocument doc(&spy);
doc.add(PrintableString<PrintOneCharacterAtATime>("Hello World!"));
doc.add(PrintableString<PrintAllAtOnce>("Hello World!"));
REQUIRE(doc.size() == 2);
CHECK(doc[0] == "Hello World!");
CHECK(doc[1] == "Hello World!");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool())
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(sizeofString(31),

View File

@@ -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);

View File

@@ -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,8 +29,8 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::IncompleteInput);
CHECK(doc.as<std::string>() == "{}");
CHECK(allocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Deallocate(sizeofString(31)));
}
@@ -40,8 +40,8 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::IncompleteInput);
CHECK(doc.as<std::string>() == "{}");
CHECK(allocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Deallocate(sizeofString(31)));
}
@@ -50,8 +50,8 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::IncompleteInput);
CHECK(doc.as<std::string>() == "{}");
CHECK(allocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Deallocate(sizeofString(31)));
}
@@ -60,8 +60,8 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::IncompleteInput);
CHECK(doc.as<std::string>() == "{}");
CHECK(allocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Deallocate(sizeofString(31)));
}
@@ -71,7 +71,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"include\":42}");
CHECK(allocator.log() ==
CHECK(spy.log() ==
AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Reallocate(sizeofString(31), sizeofString(7))
@@ -83,8 +83,8 @@ TEST_CASE("deserializeMsgPack() filter") {
filterOpt);
CHECK(error == DeserializationError::InvalidInput);
CHECK(allocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(sizeofString(31))
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Deallocate(sizeofString(31)));
}
@@ -94,7 +94,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() ==
"{\"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<std::string>() ==
"{\"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<std::string>() ==
"{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "{\"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<std::string>() == "[]");
CHECK(allocator.log() == AllocatorLog());
CHECK(spy.log() == AllocatorLog());
}
}
@@ -1199,7 +1199,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "[1,2,3]");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()));
}
}
@@ -1221,7 +1221,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() ==
"{\"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<std::string>() ==
"{\"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<std::string>() ==
"{\"onlyobj\":{\"measure\":2},\"include\":42}");
CHECK(allocator.log() ==
CHECK(spy.log() ==
AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
@@ -1302,7 +1302,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1313,8 +1313,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip false") {
@@ -1323,7 +1323,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1334,8 +1334,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip true") {
@@ -1344,7 +1344,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1355,8 +1355,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip positive fixint") {
@@ -1365,7 +1365,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1376,8 +1376,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip negative fixint") {
@@ -1386,7 +1386,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1397,8 +1397,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip uint 8") {
@@ -1407,7 +1407,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1418,8 +1418,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip uint 16") {
@@ -1428,7 +1428,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1439,8 +1439,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip uint 32") {
@@ -1449,7 +1449,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1460,8 +1460,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip uint 64") {
@@ -1472,7 +1472,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1483,8 +1483,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip int 8") {
@@ -1493,7 +1493,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1504,8 +1504,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip int 16") {
@@ -1514,7 +1514,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1525,8 +1525,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip int 32") {
@@ -1535,7 +1535,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1546,8 +1546,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip int 64") {
@@ -1558,7 +1558,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1569,8 +1569,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip float 32") {
@@ -1579,7 +1579,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1590,8 +1590,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip float 64") {
@@ -1602,7 +1602,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1613,8 +1613,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip fixstr") {
@@ -1623,7 +1623,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1634,8 +1634,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip str 8") {
@@ -1657,7 +1657,7 @@ TEST_CASE("deserializeMsgPack() filter") {
doc, "\x82\xA7onlyobj\xdb\x00\x00\x00\x05hello\xA7include\x2A",
filterOpt);
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1668,8 +1668,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip fixarray") {
@@ -1678,7 +1678,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1689,8 +1689,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip array 16") {
@@ -1701,7 +1701,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1712,8 +1712,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
SECTION("skip array 32") {
@@ -1725,7 +1725,7 @@ TEST_CASE("deserializeMsgPack() filter") {
CHECK(error == DeserializationError::Ok);
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
CHECK(allocator.log() == AllocatorLog()
CHECK(spy.log() == AllocatorLog()
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "onlyarr"
@@ -1736,8 +1736,8 @@ TEST_CASE("deserializeMsgPack() filter") {
// string builder's buffer
<< AllocatorLog::Allocate(sizeofString(31))
// string "include"
<< AllocatorLog::Reallocate(
sizeofString(31), sizeofString(7)));
<< AllocatorLog::Reallocate(sizeofString(31),
sizeofString(7)));
}
}

View File

@@ -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") {

View File

@@ -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();

View File

@@ -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()
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,7 +48,7 @@ TEST_CASE("ResourceManager::swap()") {
REQUIRE(a1->data() == b.getSlot(a1.id())->data());
REQUIRE(b1->data() == a.getSlot(b1.id())->data());
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()) *
(ARDUINOJSON_INITIAL_POOL_COUNT + 1)
<< AllocatorLog::Allocate(sizeofPoolList(
@@ -57,10 +57,10 @@ TEST_CASE("ResourceManager::swap()") {
}
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,7 +69,7 @@ TEST_CASE("ResourceManager::swap()") {
REQUIRE(a1->data() == b.getSlot(a1.id())->data());
REQUIRE(b1->data() == a.getSlot(b1.id())->data());
REQUIRE(allocator.log() == AllocatorLog()
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()) *
ARDUINOJSON_INITIAL_POOL_COUNT
<< AllocatorLog::Allocate(sizeofPoolList(
@@ -78,10 +78,10 @@ TEST_CASE("ResourceManager::swap()") {
}
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();