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,7 @@
#include <catch.hpp>
#include "Allocators.hpp"
#include "Literals.hpp"
template <typename T>
static void checkValue(const char* input, T expected) {
@@ -123,21 +124,171 @@ TEST_CASE("deserialize MsgPack value") {
SECTION("fixstr") {
checkValue<std::string>("\xA0", std::string(""));
checkValue<std::string>("\xABhello world", std::string("hello world"));
checkValue<std::string>("\xABhello world", "hello world"_s);
checkValue<std::string>("\xBFhello world hello world hello !",
std::string("hello world hello world hello !"));
"hello world hello world hello !"_s);
}
SECTION("str 8") {
checkValue<std::string>("\xd9\x05hello", std::string("hello"));
checkValue<std::string>("\xd9\x05hello", "hello"_s);
}
SECTION("str 16") {
checkValue<std::string>("\xda\x00\x05hello", std::string("hello"));
checkValue<std::string>("\xda\x00\x05hello", "hello"_s);
}
SECTION("str 32") {
checkValue<std::string>("\xdb\x00\x00\x00\x05hello", std::string("hello"));
checkValue<std::string>("\xdb\x00\x00\x00\x05hello", "hello"_s);
}
SECTION("bin 8") {
JsonDocument doc;
DeserializationError error = deserializeMsgPack(doc, "\xc4\x01?");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackBinary>());
auto binary = doc.as<MsgPackBinary>();
REQUIRE(binary.size() == 1);
REQUIRE(binary.data() != nullptr);
REQUIRE(reinterpret_cast<const char*>(binary.data())[0] == '?');
}
SECTION("bin 16") {
JsonDocument doc;
auto str = std::string(256, '?');
auto input = "\xc5\x01\x00"_s + str;
DeserializationError error = deserializeMsgPack(doc, input);
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackBinary>());
auto binary = doc.as<MsgPackBinary>();
REQUIRE(binary.size() == 0x100);
REQUIRE(binary.data() != nullptr);
REQUIRE(std::string(reinterpret_cast<const char*>(binary.data()),
binary.size()) == str);
}
SECTION("fixext 1") {
JsonDocument doc;
auto error = deserializeMsgPack(doc, "\xd4\x01\x02");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackExtension>());
auto ext = doc.as<MsgPackExtension>();
REQUIRE(ext.type() == 1);
REQUIRE(ext.size() == 1);
auto data = reinterpret_cast<const uint8_t*>(ext.data());
REQUIRE(data[0] == 2);
}
SECTION("fixext 2") {
JsonDocument doc;
auto error = deserializeMsgPack(doc, "\xd5\x01\x02\x03");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackExtension>());
auto ext = doc.as<MsgPackExtension>();
REQUIRE(ext.type() == 1);
REQUIRE(ext.size() == 2);
auto data = reinterpret_cast<const uint8_t*>(ext.data());
REQUIRE(data[0] == 2);
REQUIRE(data[1] == 3);
}
SECTION("fixext 4") {
JsonDocument doc;
auto error = deserializeMsgPack(doc, "\xd6\x01\x02\x03\x04\x05");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackExtension>());
auto ext = doc.as<MsgPackExtension>();
REQUIRE(ext.type() == 1);
REQUIRE(ext.size() == 4);
auto data = reinterpret_cast<const uint8_t*>(ext.data());
REQUIRE(data[0] == 2);
REQUIRE(data[1] == 3);
REQUIRE(data[2] == 4);
REQUIRE(data[3] == 5);
}
SECTION("fixext 8") {
JsonDocument doc;
auto error = deserializeMsgPack(doc, "\xd7\x01????????");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackExtension>());
auto ext = doc.as<MsgPackExtension>();
REQUIRE(ext.type() == 1);
REQUIRE(ext.size() == 8);
auto data = reinterpret_cast<const uint8_t*>(ext.data());
REQUIRE(data[0] == '?');
REQUIRE(data[7] == '?');
}
SECTION("fixext 16") {
JsonDocument doc;
auto error = deserializeMsgPack(doc, "\xd8\x01?????????????????");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackExtension>());
auto ext = doc.as<MsgPackExtension>();
REQUIRE(ext.type() == 1);
REQUIRE(ext.size() == 16);
auto data = reinterpret_cast<const uint8_t*>(ext.data());
REQUIRE(data[0] == '?');
REQUIRE(data[15] == '?');
}
SECTION("ext 8") {
JsonDocument doc;
auto error = deserializeMsgPack(doc, "\xc7\x02\x01\x03\x04");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackExtension>());
auto ext = doc.as<MsgPackExtension>();
REQUIRE(ext.type() == 1);
REQUIRE(ext.size() == 2);
auto data = reinterpret_cast<const uint8_t*>(ext.data());
REQUIRE(data[0] == 3);
REQUIRE(data[1] == 4);
}
SECTION("ext 16") {
JsonDocument doc;
auto error = deserializeMsgPack(doc, "\xc8\x00\x02\x01\x03\x04");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackExtension>());
auto ext = doc.as<MsgPackExtension>();
REQUIRE(ext.type() == 1);
REQUIRE(ext.size() == 2);
auto data = reinterpret_cast<const uint8_t*>(ext.data());
REQUIRE(data[0] == 3);
REQUIRE(data[1] == 4);
}
SECTION("ext 32") {
JsonDocument doc;
auto error = deserializeMsgPack(doc, "\xc9\x00\x00\x00\x02\x01\x03\x04");
REQUIRE(error == DeserializationError::Ok);
REQUIRE(doc.is<MsgPackExtension>());
auto ext = doc.as<MsgPackExtension>();
REQUIRE(ext.type() == 1);
REQUIRE(ext.size() == 2);
auto data = reinterpret_cast<const uint8_t*>(ext.data());
REQUIRE(data[0] == 3);
REQUIRE(data[1] == 4);
}
}
@@ -198,12 +349,12 @@ TEST_CASE("deserializeMsgPack() under memory constaints") {
checkError(0, "\x80", DeserializationError::Ok);
}
SECTION("{H:1}") {
checkError(0, "\x81\xA1H\x01", DeserializationError::NoMemory);
checkError(3, "\x81\xA1H\x01", DeserializationError::Ok);
checkError(1, "\x81\xA1H\x01", DeserializationError::NoMemory);
checkError(2, "\x81\xA1H\x01", DeserializationError::Ok);
}
SECTION("{H:1,W:2}") {
checkError(3, "\x82\xA1H\x01\xA1W\x02", DeserializationError::NoMemory);
checkError(5, "\x82\xA1H\x01\xA1W\x02", DeserializationError::Ok);
checkError(2, "\x82\xA1H\x01\xA1W\x02", DeserializationError::NoMemory);
checkError(3, "\x82\xA1H\x01\xA1W\x02", DeserializationError::Ok);
}
}
@@ -212,13 +363,13 @@ TEST_CASE("deserializeMsgPack() under memory constaints") {
checkError(0, "\xDE\x00\x00", DeserializationError::Ok);
}
SECTION("{H:1}") {
checkError(2, "\xDE\x00\x01\xA1H\x01", DeserializationError::NoMemory);
checkError(3, "\xDE\x00\x01\xA1H\x01", DeserializationError::Ok);
checkError(1, "\xDE\x00\x01\xA1H\x01", DeserializationError::NoMemory);
checkError(2, "\xDE\x00\x01\xA1H\x01", DeserializationError::Ok);
}
SECTION("{H:1,W:2}") {
checkError(3, "\xDE\x00\x02\xA1H\x01\xA1W\x02",
checkError(2, "\xDE\x00\x02\xA1H\x01\xA1W\x02",
DeserializationError::NoMemory);
checkError(5, "\xDE\x00\x02\xA1H\x01\xA1W\x02", DeserializationError::Ok);
checkError(3, "\xDE\x00\x02\xA1H\x01\xA1W\x02", DeserializationError::Ok);
}
}
@@ -227,14 +378,14 @@ TEST_CASE("deserializeMsgPack() under memory constaints") {
checkError(0, "\xDF\x00\x00\x00\x00", DeserializationError::Ok);
}
SECTION("{H:1}") {
checkError(2, "\xDF\x00\x00\x00\x01\xA1H\x01",
checkError(1, "\xDF\x00\x00\x00\x01\xA1H\x01",
DeserializationError::NoMemory);
checkError(3, "\xDF\x00\x00\x00\x01\xA1H\x01", DeserializationError::Ok);
checkError(2, "\xDF\x00\x00\x00\x01\xA1H\x01", DeserializationError::Ok);
}
SECTION("{H:1,W:2}") {
checkError(3, "\xDF\x00\x00\x00\x02\xA1H\x01\xA1W\x02",
checkError(2, "\xDF\x00\x00\x00\x02\xA1H\x01\xA1W\x02",
DeserializationError::NoMemory);
checkError(5, "\xDF\x00\x00\x00\x02\xA1H\x01\xA1W\x02",
checkError(3, "\xDF\x00\x00\x00\x02\xA1H\x01\xA1W\x02",
DeserializationError::Ok);
}
}