unbound.cpp 722 B

1234567891011121314151617181920212223242526272829303132333435
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2022, Benoit BLANCHON
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. using namespace Catch::Matchers;
  7. TEST_CASE("Unbound JsonArray") {
  8. JsonArray array;
  9. SECTION("SubscriptFails") {
  10. REQUIRE(array[0].isNull());
  11. }
  12. SECTION("AddFails") {
  13. array.add(1);
  14. REQUIRE(0 == array.size());
  15. }
  16. SECTION("CreateNestedArrayFails") {
  17. REQUIRE(array.createNestedArray().isNull());
  18. }
  19. SECTION("CreateNestedObjectFails") {
  20. REQUIRE(array.createNestedObject().isNull());
  21. }
  22. SECTION("PrintToWritesBrackets") {
  23. char buffer[32];
  24. serializeJson(array, buffer, sizeof(buffer));
  25. REQUIRE_THAT(buffer, Equals("null"));
  26. }
  27. }