Files
ArduinoJson/test/JsonObject_Invalid_Tests.cpp
Benoit Blanchon aa2ef79e55 Templatized all functions using String or std::string
* Removed `ArduinoJson::String`
* Removed `JsonVariant::defaultValue<T>()`
* Removed non-template `JsonObject::get()` and `JsonArray.get()`
* Fixed support for `StringSumHelper` (issue #184)
* Replaced `ARDUINOJSON_USE_ARDUINO_STRING` by `ARDUINOJSON_ENABLE_STD_STRING` and `ARDUINOJSON_ENABLE_ARDUINO_STRING` (issue #378)
* Added example `StringExample.ino` to show where `String` can be used
2016-11-06 17:52:18 +01:00

34 lines
924 B
C++

// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#include <ArduinoJson.h>
#include <gtest/gtest.h>
TEST(JsonObject_Invalid_Tests, SubscriptFails) {
ASSERT_FALSE(JsonObject::invalid()["key"].success());
}
TEST(JsonObject_Invalid_Tests, AddFails) {
JsonObject& object = JsonObject::invalid();
object.set("hello", "world");
ASSERT_EQ(0, object.size());
}
TEST(JsonObject_Invalid_Tests, CreateNestedArrayFails) {
ASSERT_FALSE(JsonObject::invalid().createNestedArray("hello").success());
}
TEST(JsonObject_Invalid_Tests, CreateNestedObjectFails) {
ASSERT_FALSE(JsonObject::invalid().createNestedObject("world").success());
}
TEST(JsonObject_Invalid_Tests, PrintToWritesBraces) {
char buffer[32];
JsonObject::invalid().printTo(buffer, sizeof(buffer));
ASSERT_STREQ("{}", buffer);
}