// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2018 // MIT License #include #include #include using namespace ARDUINOJSON_NAMESPACE; TEST_CASE("StringBuilder") { SECTION("WorksWhenBufferIsBigEnough") { StaticMemoryPool memoryPool; StringBuilder str(&memoryPool); str.append("hello"); REQUIRE(str.complete().equals("hello")); } SECTION("ReturnsNullWhenTooSmall") { StaticMemoryPool<1> memoryPool; StringBuilder str(&memoryPool); str.append("hello!!!"); REQUIRE(str.complete().isNull()); } SECTION("Increases size of memory pool") { StaticMemoryPool memoryPool; StringBuilder str(&memoryPool); str.append('h'); str.complete(); REQUIRE(JSON_STRING_SIZE(2) == memoryPool.size()); } }