Files
ArduinoJson/test/JsonObject/invalid.cpp
Benoit Blanchon 1a4515c0b9 Removed JsonArray::is<T>(i) and JsonArray::set(i,v)
Removed `JsonObject::is<T>(k)` and `JsonObject::set(k,v)`
Replaced `T JsonArray::get<T>(i)` with `JsonVariant JsonArray::get(i)`
Replaced `T JsonObject::get<T>(k)` with `JsonVariant JsonObject::get(k)`
2018-10-18 14:51:02 +02:00

36 lines
729 B
C++

// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace Catch::Matchers;
TEST_CASE("JsonObject::invalid()") {
JsonObject obj;
SECTION("SubscriptFails") {
REQUIRE(obj["key"].isNull());
}
SECTION("AddFails") {
obj["hello"] = "world";
REQUIRE(0 == obj.size());
}
SECTION("CreateNestedArrayFails") {
REQUIRE(obj.createNestedArray("hello").isNull());
}
SECTION("CreateNestedObjectFails") {
REQUIRE(obj.createNestedObject("world").isNull());
}
SECTION("serialize to 'null'") {
char buffer[32];
serializeJson(obj, buffer, sizeof(buffer));
REQUIRE_THAT(buffer, Equals("null"));
}
}