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

@@ -7,6 +7,8 @@
#include <sstream>
#include "Allocators.hpp"
TEST_CASE("deserializeMsgPack() returns InvalidInput") {
JsonDocument doc;
@@ -182,84 +184,18 @@ TEST_CASE("deserializeMsgPack() returns IncompleteInput") {
}
}
static std::string msgPackToJson(const char* input, size_t inputSize) {
JsonDocument doc;
auto err = deserializeMsgPack(doc, input, inputSize);
REQUIRE(err == DeserializationError::Ok);
return doc.as<std::string>();
}
TEST_CASE(
"deserializeMsgPack() returns NoMemory when string allocation fails") {
TimebombAllocator allocator(0);
JsonDocument doc(&allocator);
SECTION("fixstr") {
DeserializationError err = deserializeMsgPack(doc, "\xA5hello", 9);
REQUIRE(err == DeserializationError::NoMemory);
}
TEST_CASE("deserializeMsgPack() replaces unsupported types by null") {
SECTION("bin 8") {
REQUIRE(msgPackToJson("\x92\xc4\x01X\x2A", 5) == "[null,42]");
}
SECTION("bin 16") {
REQUIRE(msgPackToJson("\x92\xc5\x00\x01X\x2A", 6) == "[null,42]");
}
SECTION("bin 32") {
REQUIRE(msgPackToJson("\x92\xc6\x00\x00\x00\x01X\x2A", 8) == "[null,42]");
}
SECTION("ext 8") {
REQUIRE(msgPackToJson("\x92\xc7\x01\x01\x01\x2A", 6) == "[null,42]");
}
SECTION("ext 16") {
REQUIRE(msgPackToJson("\x92\xc8\x00\x01\x01\x01\x2A", 7) == "[null,42]");
}
SECTION("ext 32") {
REQUIRE(msgPackToJson("\x92\xc9\x00\x00\x00\x01\x01\x01\x2A", 9) ==
"[null,42]");
}
SECTION("fixext 1") {
REQUIRE(msgPackToJson("\x92\xd4\x01\x01\x2A", 5) == "[null,42]");
}
SECTION("fixext 2") {
REQUIRE(msgPackToJson("\x92\xd5\x01\x01\x02\x2A", 6) == "[null,42]");
}
SECTION("fixext 4") {
REQUIRE(msgPackToJson("\x92\xd6\x01\x01\x02\x03\x04\x2A", 8) ==
"[null,42]");
}
SECTION("fixext 8") {
REQUIRE(msgPackToJson("\x92\xd7\x01\x01\x02\x03\x04\x05\x06\x07\x08\x2A",
12) == "[null,42]");
}
SECTION("fixext 16") {
REQUIRE(msgPackToJson("\x92\xd8\x01\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A"
"\x0B\x0C\x0D\x0E"
"\x0F\x10\x2A",
20) == "[null,42]");
}
}
TEST_CASE("deserializeMsgPack() returns NoMemory is string length overflows") {
JsonDocument doc;
auto maxLength = ArduinoJson::detail::StringNode::maxLength;
SECTION("max length should succeed") {
auto len = maxLength;
std::string prefix = {'\xdb', char(len >> 24), char(len >> 16),
char(len >> 8), char(len)};
auto err = deserializeMsgPack(doc, prefix + std::string(len, 'a'));
REQUIRE(err == DeserializationError::Ok);
}
SECTION("one above max length should fail") {
auto len = maxLength + 1;
std::string prefix = {'\xdb', char(len >> 24), char(len >> 16),
char(len >> 8), char(len)};
auto err = deserializeMsgPack(doc, prefix + std::string(len, 'a'));
DeserializationError err = deserializeMsgPack(doc, "\xC4\x01X", 3);
REQUIRE(err == DeserializationError::NoMemory);
}
}