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:
iranl
2024-08-11 11:20:31 +02:00
committed by GitHub
parent 4af90cbc79
commit 9d55c2173d
216 changed files with 6437 additions and 5705 deletions

View File

@@ -6,6 +6,9 @@
#include <stdint.h>
#include <catch.hpp>
#include "Allocators.hpp"
#include "Literals.hpp"
TEST_CASE("JsonVariant::add(T)") {
JsonDocument doc;
JsonVariant var = doc.to<JsonVariant>();
@@ -23,7 +26,7 @@ TEST_CASE("JsonVariant::add(T)") {
}
SECTION("add std::string to new variant") {
var.add(std::string("hello"));
var.add("hello"_s);
REQUIRE(var.as<std::string>() == "[\"hello\"]");
}
@@ -56,15 +59,58 @@ TEST_CASE("JsonVariant::add<T>()") {
REQUIRE(doc.as<std::string>() == "[[1,2]]");
}
SECTION("JsonObject") {
JsonObject object = var.add<JsonObject>();
object["hello"] = "world";
REQUIRE(doc.as<std::string>() == "[{\"hello\":\"world\"}]");
}
SECTION("JsonVariant") {
JsonVariant variant = var.add<JsonVariant>();
variant.set(42);
REQUIRE(doc.as<std::string>() == "[42]");
}
}
TEST_CASE("JsonObject::add(JsonObject) ") {
JsonDocument doc1;
doc1["hello"_s] = "world"_s;
TimebombAllocator allocator(10);
SpyingAllocator spy(&allocator);
JsonDocument doc2(&spy);
JsonVariant variant = doc2.to<JsonVariant>();
SECTION("success") {
bool result = variant.add(doc1.as<JsonObject>());
REQUIRE(result == true);
REQUIRE(doc2.as<std::string>() == "[{\"hello\":\"world\"}]");
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
Allocate(sizeofString("world")),
});
}
SECTION("partial failure") { // issue #2081
allocator.setCountdown(2);
bool result = variant.add(doc1.as<JsonObject>());
REQUIRE(result == false);
REQUIRE(doc2.as<std::string>() == "[]");
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Allocate(sizeofString("hello")),
AllocateFail(sizeofString("world")),
Deallocate(sizeofString("hello")),
});
}
SECTION("complete failure") {
allocator.setCountdown(0);
bool result = variant.add(doc1.as<JsonObject>());
REQUIRE(result == false);
REQUIRE(doc2.as<std::string>() == "[]");
REQUIRE(spy.log() == AllocatorLog{
AllocateFail(sizeofPool()),
});
}
}