invalid.cpp 729 B

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