forked from bblanchon/ArduinoJson
Replace add()
with add<T>()
(add(T)
is still supported)
This commit is contained in:
@@ -9,7 +9,7 @@ typedef ArduinoJson::detail::ElementProxy<JsonDocument&> ElementProxy;
|
||||
|
||||
TEST_CASE("ElementProxy::add()") {
|
||||
JsonDocument doc;
|
||||
doc.add();
|
||||
doc.add<JsonVariant>();
|
||||
ElementProxy ep = doc[0];
|
||||
|
||||
SECTION("add(int)") {
|
||||
@@ -35,7 +35,7 @@ TEST_CASE("ElementProxy::add()") {
|
||||
|
||||
TEST_CASE("ElementProxy::clear()") {
|
||||
JsonDocument doc;
|
||||
doc.add();
|
||||
doc.add<JsonVariant>();
|
||||
ElementProxy ep = doc[0];
|
||||
|
||||
SECTION("size goes back to zero") {
|
||||
@@ -95,7 +95,7 @@ TEST_CASE("ElementProxy::operator==()") {
|
||||
|
||||
TEST_CASE("ElementProxy::remove()") {
|
||||
JsonDocument doc;
|
||||
doc.add();
|
||||
doc.add<JsonVariant>();
|
||||
ElementProxy ep = doc[0];
|
||||
|
||||
SECTION("remove(int)") {
|
||||
@@ -168,7 +168,7 @@ TEST_CASE("ElementProxy::set()") {
|
||||
|
||||
TEST_CASE("ElementProxy::size()") {
|
||||
JsonDocument doc;
|
||||
doc.add();
|
||||
doc.add<JsonVariant>();
|
||||
ElementProxy ep = doc[0];
|
||||
|
||||
SECTION("returns 0") {
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
using ArduinoJson::detail::sizeofArray;
|
||||
|
||||
TEST_CASE("JsonDocument::add()") {
|
||||
TEST_CASE("JsonDocument::add(T)") {
|
||||
SpyingAllocator spy;
|
||||
JsonDocument doc(&spy);
|
||||
|
||||
@@ -79,3 +79,26 @@ TEST_CASE("JsonDocument::add()") {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("JsonDocument::add<T>()") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("JsonArray") {
|
||||
JsonArray array = doc.add<JsonArray>();
|
||||
array.add(1);
|
||||
array.add(2);
|
||||
REQUIRE(doc.as<std::string>() == "[[1,2]]");
|
||||
}
|
||||
|
||||
SECTION("JsonObject") {
|
||||
JsonObject object = doc.add<JsonObject>();
|
||||
object["hello"] = "world";
|
||||
REQUIRE(doc.as<std::string>() == "[{\"hello\":\"world\"}]");
|
||||
}
|
||||
|
||||
SECTION("JsonVariant") {
|
||||
JsonVariant variant = doc.add<JsonVariant>();
|
||||
variant.set(42);
|
||||
REQUIRE(doc.as<std::string>() == "[42]");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user