unbound.cpp 536 B

123456789101112131415161718192021222324252627
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2025, 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("PrintToWritesBrackets") {
  17. char buffer[32];
  18. serializeJson(array, buffer, sizeof(buffer));
  19. REQUIRE_THAT(buffer, Equals("null"));
  20. }
  21. }