Extracted VariantData and CollectionData classes

This commit is contained in:
Benoit Blanchon
2018-12-07 09:16:58 +01:00
parent 1ad97ebf85
commit b77b203935
45 changed files with 1129 additions and 1007 deletions

View File

@ -12,30 +12,30 @@ static char buffer[4096];
TEST_CASE("StringBuilder") {
SECTION("Works when buffer is big enough") {
MemoryPool memoryPool(buffer, addPadding(JSON_STRING_SIZE(6)));
MemoryPool pool(buffer, addPadding(JSON_STRING_SIZE(6)));
StringBuilder str(&memoryPool);
StringBuilder str(&pool);
str.append("hello");
REQUIRE(str.complete().equals("hello"));
REQUIRE(str.complete() == std::string("hello"));
}
SECTION("Returns null when too small") {
MemoryPool memoryPool(buffer, sizeof(void*));
MemoryPool pool(buffer, sizeof(void*));
StringBuilder str(&memoryPool);
StringBuilder str(&pool);
str.append("hello world!");
REQUIRE(str.complete().isNull());
REQUIRE(str.complete() == 0);
}
SECTION("Increases size of memory pool") {
MemoryPool memoryPool(buffer, addPadding(JSON_STRING_SIZE(6)));
MemoryPool pool(buffer, addPadding(JSON_STRING_SIZE(6)));
StringBuilder str(&memoryPool);
StringBuilder str(&pool);
str.append('h');
str.complete();
REQUIRE(JSON_STRING_SIZE(2) == memoryPool.size());
REQUIRE(JSON_STRING_SIZE(2) == pool.size());
}
}