mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-23 07:17:30 +02:00
Added tests of JsonArray::invalid() and JsonObject::invalid()
This commit is contained in:
36
test/JsonArray_Invalid_Tests.cpp
Normal file
36
test/JsonArray_Invalid_Tests.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright Benoit Blanchon 2014
|
||||||
|
// MIT License
|
||||||
|
//
|
||||||
|
// Arduino JSON library
|
||||||
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
|
TEST(JsonArray_Invalid_Tests, AtFails) {
|
||||||
|
ASSERT_FALSE(JsonArray::invalid().at(0).success());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(JsonArray_Invalid_Tests, SubscriptFails) {
|
||||||
|
ASSERT_FALSE(JsonArray::invalid()[0].success());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(JsonArray_Invalid_Tests, AddFails) {
|
||||||
|
JsonArray& array = JsonArray::invalid();
|
||||||
|
array.add(1);
|
||||||
|
ASSERT_EQ(0, array.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(JsonArray_Invalid_Tests, CreateNestedArrayFails) {
|
||||||
|
ASSERT_FALSE(JsonArray::invalid().createNestedArray().success());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(JsonArray_Invalid_Tests, CreateNestedObjectFails) {
|
||||||
|
ASSERT_FALSE(JsonArray::invalid().createNestedObject().success());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(JsonArray_Invalid_Tests, PrintToWritesBrackets) {
|
||||||
|
char buffer[32];
|
||||||
|
JsonArray::invalid().printTo(buffer, sizeof(buffer));
|
||||||
|
ASSERT_STREQ("[]", buffer);
|
||||||
|
}
|
36
test/JsonObject_Invalid_Tests.cpp
Normal file
36
test/JsonObject_Invalid_Tests.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright Benoit Blanchon 2014
|
||||||
|
// MIT License
|
||||||
|
//
|
||||||
|
// Arduino JSON library
|
||||||
|
// https://github.com/bblanchon/ArduinoJson
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
|
TEST(JsonObject_Invalid_Tests, AtFails) {
|
||||||
|
ASSERT_FALSE(JsonObject::invalid().at(0).success());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(JsonObject_Invalid_Tests, SubscriptFails) {
|
||||||
|
ASSERT_FALSE(JsonObject::invalid()[0].success());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(JsonObject_Invalid_Tests, AddFails) {
|
||||||
|
JsonObject& array = JsonObject::invalid();
|
||||||
|
array.add("hello", "world");
|
||||||
|
ASSERT_EQ(0, array.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);
|
||||||
|
}
|
Reference in New Issue
Block a user