isNull.cpp 640 B

12345678910111213141516171819202122232425
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2018
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. TEST_CASE("JsonArray::isNull()") {
  7. SECTION("returns true for undefined JsonArray") {
  8. JsonArray array;
  9. REQUIRE(array.isNull() == true);
  10. }
  11. SECTION("returns false when allocation succeeds") {
  12. StaticJsonDocument<JSON_ARRAY_SIZE(0)> doc;
  13. JsonArray array = doc.to<JsonArray>();
  14. REQUIRE(array.isNull() == false);
  15. }
  16. SECTION("returns true when allocation fails") {
  17. StaticJsonDocument<1> doc;
  18. JsonArray array = doc.to<JsonArray>();
  19. REQUIRE(array.isNull() == true);
  20. }
  21. }