// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #include #include TEST_CASE("StaticJsonBuffer::parseObject()") { SECTION("TooSmallBufferForEmptyObject") { StaticJsonBuffer bufferTooSmall; char input[] = "{}"; JsonObject& obj = bufferTooSmall.parseObject(input); REQUIRE_FALSE(obj.success()); } SECTION("BufferOfTheRightSizeForEmptyObject") { StaticJsonBuffer bufferOfRightSize; char input[] = "{}"; JsonObject& obj = bufferOfRightSize.parseObject(input); REQUIRE(obj.success()); } SECTION("TooSmallBufferForObjectWithOneValue") { StaticJsonBuffer bufferTooSmall; char input[] = "{\"a\":1}"; JsonObject& obj = bufferTooSmall.parseObject(input); REQUIRE_FALSE(obj.success()); } SECTION("BufferOfTheRightSizeForObjectWithOneValue") { StaticJsonBuffer bufferOfRightSize; char input[] = "{\"a\":1}"; JsonObject& obj = bufferOfRightSize.parseObject(input); REQUIRE(obj.success()); } SECTION("TooSmallBufferForObjectWithNestedObject") { StaticJsonBuffer bufferTooSmall; char input[] = "{\"a\":[]}"; JsonObject& obj = bufferTooSmall.parseObject(input); REQUIRE_FALSE(obj.success()); } SECTION("BufferOfTheRightSizeForObjectWithNestedObject") { StaticJsonBuffer bufferOfRightSize; char input[] = "{\"a\":[]}"; JsonObject& obj = bufferOfRightSize.parseObject(input); REQUIRE(obj.success()); } SECTION("CharPtrNull") { REQUIRE_FALSE( StaticJsonBuffer<100>().parseObject(static_cast(0)).success()); } SECTION("ConstCharPtrNull") { REQUIRE_FALSE(StaticJsonBuffer<100>() .parseObject(static_cast(0)) .success()); } }