Update ArduinoJSON, esp-nimble-cpp, Arduino Core, ESP-IDF (#448)
* ArduinoJSON 7.1.0 * Update nimble and arduino core * Update nuki_ble
This commit is contained in:
@@ -6,12 +6,12 @@ add_executable(JsonObjectTests
|
||||
clear.cpp
|
||||
compare.cpp
|
||||
containsKey.cpp
|
||||
copy.cpp
|
||||
equals.cpp
|
||||
isNull.cpp
|
||||
iterator.cpp
|
||||
nesting.cpp
|
||||
remove.cpp
|
||||
set.cpp
|
||||
size.cpp
|
||||
std_string.cpp
|
||||
subscript.cpp
|
||||
|
||||
@@ -30,4 +30,10 @@ TEST_CASE("JsonObject::containsKey()") {
|
||||
REQUIRE(true == obj.containsKey(vla));
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("key is a JsonVariant") {
|
||||
doc["key"] = "hello";
|
||||
REQUIRE(true == obj.containsKey(obj["key"]));
|
||||
REQUIRE(false == obj.containsKey(obj["hello"]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +80,10 @@ TEST_CASE("JsonObject::remove()") {
|
||||
JsonObject unboundObject;
|
||||
unboundObject.remove(unboundObject.begin());
|
||||
}
|
||||
|
||||
SECTION("remove(JsonVariant)") {
|
||||
obj["key"] = "b";
|
||||
obj.remove(obj["key"]);
|
||||
REQUIRE("{\"a\":0,\"c\":2,\"key\":\"b\"}" == doc.as<std::string>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Allocators.hpp"
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("JsonObject::set()") {
|
||||
SpyingAllocator spy;
|
||||
@@ -22,20 +23,20 @@ TEST_CASE("JsonObject::set()") {
|
||||
bool success = obj2.set(obj1);
|
||||
|
||||
REQUIRE(success == true);
|
||||
REQUIRE(obj2["hello"] == std::string("world"));
|
||||
REQUIRE(obj2["hello"] == "world"_s);
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofPool()),
|
||||
});
|
||||
}
|
||||
|
||||
SECTION("copy local string value") {
|
||||
obj1["hello"] = std::string("world");
|
||||
obj1["hello"] = "world"_s;
|
||||
spy.clearLog();
|
||||
|
||||
bool success = obj2.set(obj1);
|
||||
|
||||
REQUIRE(success == true);
|
||||
REQUIRE(obj2["hello"] == std::string("world"));
|
||||
REQUIRE(obj2["hello"] == "world"_s);
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofPool()),
|
||||
Allocate(sizeofString("world")),
|
||||
@@ -43,13 +44,13 @@ TEST_CASE("JsonObject::set()") {
|
||||
}
|
||||
|
||||
SECTION("copy local key") {
|
||||
obj1[std::string("hello")] = "world";
|
||||
obj1["hello"_s] = "world";
|
||||
spy.clearLog();
|
||||
|
||||
bool success = obj2.set(obj1);
|
||||
|
||||
REQUIRE(success == true);
|
||||
REQUIRE(obj2["hello"] == std::string("world"));
|
||||
REQUIRE(obj2["hello"] == "world"_s);
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofString("hello")),
|
||||
Allocate(sizeofPool()),
|
||||
@@ -63,7 +64,7 @@ TEST_CASE("JsonObject::set()") {
|
||||
bool success = obj2.set(obj1);
|
||||
|
||||
REQUIRE(success == true);
|
||||
REQUIRE(obj2["hello"] == std::string("world"));
|
||||
REQUIRE(obj2["hello"] == "world"_s);
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofString("hello")),
|
||||
Allocate(sizeofPool()),
|
||||
@@ -78,7 +79,7 @@ TEST_CASE("JsonObject::set()") {
|
||||
bool success = obj2.set(obj1);
|
||||
|
||||
REQUIRE(success == true);
|
||||
REQUIRE(obj2["hello"] == std::string("world"));
|
||||
REQUIRE(obj2["hello"] == "world"_s);
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofString("hello")),
|
||||
Allocate(sizeofPool()),
|
||||
@@ -91,7 +92,7 @@ TEST_CASE("JsonObject::set()") {
|
||||
|
||||
obj2.set(static_cast<JsonObjectConst>(obj1));
|
||||
|
||||
REQUIRE(obj2["hello"] == std::string("world"));
|
||||
REQUIRE(obj2["hello"] == "world"_s);
|
||||
}
|
||||
|
||||
SECTION("copy fails in the middle of an object") {
|
||||
@@ -99,8 +100,8 @@ TEST_CASE("JsonObject::set()") {
|
||||
JsonDocument doc3(&timebomb);
|
||||
JsonObject obj3 = doc3.to<JsonObject>();
|
||||
|
||||
obj1[std::string("a")] = 1;
|
||||
obj1[std::string("b")] = 2;
|
||||
obj1["a"_s] = 1;
|
||||
obj1["b"_s] = 2;
|
||||
|
||||
bool success = obj3.set(obj1);
|
||||
|
||||
@@ -113,12 +114,12 @@ TEST_CASE("JsonObject::set()") {
|
||||
JsonDocument doc3(&timebomb);
|
||||
JsonObject obj3 = doc3.to<JsonObject>();
|
||||
|
||||
obj1["hello"][0] = std::string("world");
|
||||
obj1["hello"][0] = "world"_s;
|
||||
|
||||
bool success = obj3.set(obj1);
|
||||
|
||||
REQUIRE(success == false);
|
||||
REQUIRE(doc3.as<std::string>() == "{\"hello\":[null]}");
|
||||
REQUIRE(doc3.as<std::string>() == "{\"hello\":[]}");
|
||||
}
|
||||
|
||||
SECTION("destination is null") {
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
static void eraseString(std::string& str) {
|
||||
char* p = const_cast<char*>(str.c_str());
|
||||
while (*p)
|
||||
@@ -20,7 +22,7 @@ TEST_CASE("std::string") {
|
||||
deserializeJson(doc, json);
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
REQUIRE(std::string("value") == obj[std::string("key")]);
|
||||
REQUIRE("value"_s == obj["key"_s]);
|
||||
}
|
||||
|
||||
SECTION("operator[] const") {
|
||||
@@ -29,21 +31,21 @@ TEST_CASE("std::string") {
|
||||
deserializeJson(doc, json);
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
|
||||
REQUIRE(std::string("value") == obj[std::string("key")]);
|
||||
REQUIRE("value"_s == obj["key"_s]);
|
||||
}
|
||||
|
||||
SECTION("containsKey()") {
|
||||
char json[] = "{\"key\":\"value\"}";
|
||||
deserializeJson(doc, json);
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
REQUIRE(true == obj.containsKey(std::string("key")));
|
||||
REQUIRE(true == obj.containsKey("key"_s));
|
||||
}
|
||||
|
||||
SECTION("remove()") {
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj["key"] = "value";
|
||||
|
||||
obj.remove(std::string("key"));
|
||||
obj.remove("key"_s);
|
||||
|
||||
REQUIRE(0 == obj.size());
|
||||
}
|
||||
@@ -53,7 +55,7 @@ TEST_CASE("std::string") {
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj[key] = "world";
|
||||
eraseString(key);
|
||||
REQUIRE(std::string("world") == obj["hello"]);
|
||||
REQUIRE("world"_s == obj["hello"]);
|
||||
}
|
||||
|
||||
SECTION("operator[], set value") {
|
||||
@@ -61,6 +63,6 @@ TEST_CASE("std::string") {
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj["hello"] = value;
|
||||
eraseString(value);
|
||||
REQUIRE(std::string("world") == obj["hello"]);
|
||||
REQUIRE("world"_s == obj["hello"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Allocators.hpp"
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("JsonObject::operator[]") {
|
||||
SpyingAllocator spy;
|
||||
@@ -50,7 +51,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
|
||||
REQUIRE(true == obj["hello"].is<const char*>());
|
||||
REQUIRE(false == obj["hello"].is<long>());
|
||||
REQUIRE(std::string("h3110") == obj["hello"].as<const char*>());
|
||||
REQUIRE("h3110"_s == obj["hello"].as<const char*>());
|
||||
}
|
||||
|
||||
SECTION("array") {
|
||||
@@ -132,7 +133,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
}
|
||||
|
||||
SECTION("should duplicate std::string value") {
|
||||
obj["hello"] = std::string("world");
|
||||
obj["hello"] = "world"_s;
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofPool()),
|
||||
Allocate(sizeofString("world")),
|
||||
@@ -140,7 +141,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
}
|
||||
|
||||
SECTION("should duplicate std::string key") {
|
||||
obj[std::string("hello")] = "world";
|
||||
obj["hello"_s] = "world";
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofString("hello")),
|
||||
Allocate(sizeofPool()),
|
||||
@@ -148,7 +149,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
}
|
||||
|
||||
SECTION("should duplicate std::string key&value") {
|
||||
obj[std::string("hello")] = std::string("world");
|
||||
obj["hello"_s] = "world"_s;
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofString("hello")),
|
||||
Allocate(sizeofPool()),
|
||||
@@ -197,7 +198,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
|
||||
obj[vla] = "world";
|
||||
|
||||
REQUIRE(std::string("world") == obj["hello"]);
|
||||
REQUIRE("world"_s == obj["hello"]);
|
||||
}
|
||||
|
||||
SECTION("obj[str] = VLA") { // issue #416
|
||||
@@ -207,7 +208,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
|
||||
obj["hello"] = vla;
|
||||
|
||||
REQUIRE(std::string("world") == obj["hello"].as<const char*>());
|
||||
REQUIRE("world"_s == obj["hello"].as<const char*>());
|
||||
}
|
||||
|
||||
SECTION("obj.set(VLA, str)") {
|
||||
@@ -217,7 +218,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
|
||||
obj[vla] = "world";
|
||||
|
||||
REQUIRE(std::string("world") == obj["hello"]);
|
||||
REQUIRE("world"_s == obj["hello"]);
|
||||
}
|
||||
|
||||
SECTION("obj.set(str, VLA)") {
|
||||
@@ -227,7 +228,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
|
||||
obj["hello"].set(vla);
|
||||
|
||||
REQUIRE(std::string("world") == obj["hello"].as<const char*>());
|
||||
REQUIRE("world"_s == obj["hello"].as<const char*>());
|
||||
}
|
||||
|
||||
SECTION("obj[VLA]") {
|
||||
@@ -238,7 +239,7 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||
|
||||
obj = doc.as<JsonObject>();
|
||||
REQUIRE(std::string("world") == obj[vla]);
|
||||
REQUIRE("world"_s == obj[vla]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -249,4 +250,12 @@ TEST_CASE("JsonObject::operator[]") {
|
||||
REQUIRE(true == obj["hello"]["world"].is<int>());
|
||||
REQUIRE(false == obj["hello"]["world"].is<bool>());
|
||||
}
|
||||
|
||||
SECTION("JsonVariant") {
|
||||
obj["hello"] = "world";
|
||||
doc["key"] = "hello";
|
||||
|
||||
REQUIRE(obj[obj["key"]] == "world");
|
||||
REQUIRE(obj[obj["foo"]] == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user