VariantPool: store VariantSlots instead of chars

This commit is contained in:
Benoit Blanchon
2023-07-03 09:23:18 +02:00
parent 1d96826371
commit 0f511b873d
7 changed files with 51 additions and 40 deletions

View File

@ -32,15 +32,15 @@ TEST_CASE("JsonDocument assignment") {
SECTION("Copy assignment reallocates when capacity is smaller") {
JsonDocument doc1(4096, &spyingAllocator);
deserializeJson(doc1, "{\"hello\":\"world\"}");
JsonDocument doc2(8, &spyingAllocator);
deserializeJson(doc1, "[{\"hello\":\"world\"}]");
JsonDocument doc2(sizeofArray(1), &spyingAllocator);
spyingAllocator.clearLog();
doc2 = doc1;
REQUIRE(doc2.as<std::string>() == "{\"hello\":\"world\"}");
REQUIRE(doc2.as<std::string>() == "[{\"hello\":\"world\"}]");
REQUIRE(spyingAllocator.log() ==
AllocatorLog() << AllocatorLog::Deallocate(8)
AllocatorLog() << AllocatorLog::Deallocate(sizeofArray(1))
<< AllocatorLog::Allocate(4096)
<< AllocatorLog::Allocate(sizeofString(5)) // hello
<< AllocatorLog::Allocate(sizeofString(5)) // world
@ -68,7 +68,7 @@ TEST_CASE("JsonDocument assignment") {
{
JsonDocument doc1(4096, &spyingAllocator);
doc1.set(std::string("The size of this string is 32!!"));
JsonDocument doc2(8, &spyingAllocator);
JsonDocument doc2(128, &spyingAllocator);
doc2 = std::move(doc1);
@ -78,8 +78,8 @@ TEST_CASE("JsonDocument assignment") {
REQUIRE(spyingAllocator.log() ==
AllocatorLog() << AllocatorLog::Allocate(4096)
<< AllocatorLog::Allocate(sizeofString(31))
<< AllocatorLog::Allocate(8)
<< AllocatorLog::Deallocate(8)
<< AllocatorLog::Allocate(128)
<< AllocatorLog::Deallocate(128)
<< AllocatorLog::Deallocate(sizeofString(31))
<< AllocatorLog::Deallocate(4096));
}