Add MsgPack bin8/bin16/bin32 support

Closes #2078
Closes #922
This commit is contained in:
Aubrey (Sanae)
2024-04-29 14:47:40 +02:00
committed by Benoit Blanchon
parent cd4bf33132
commit 18a9a5b590
16 changed files with 358 additions and 11 deletions

View File

@ -21,6 +21,22 @@ TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 2") {
REQUIRE(doc.overflowed() == true);
}
SECTION("set() returns true if string has 65535 characters") {
auto str = std::string(65535, '?');
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
REQUIRE(result == true);
REQUIRE(doc.overflowed() == false);
}
SECTION("set() returns false if string has 65536 characters") {
auto str = std::string(65536, '?');
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
REQUIRE(result == false);
REQUIRE(doc.overflowed() == true);
}
SECTION("deserializeJson() returns Ok if string has 65535 characters") {
auto input = "\"" + std::string(65535, '?') + "\"";
@ -37,7 +53,7 @@ TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 2") {
REQUIRE(err == DeserializationError::NoMemory);
}
SECTION("deserializeMsgPack() returns Ok of string has 65535 characters") {
SECTION("deserializeMsgPack() returns Ok if string has 65535 characters") {
auto input = "\xda\xff\xff" + std::string(65535, '?');
auto err = deserializeMsgPack(doc, input);
@ -46,7 +62,7 @@ TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 2") {
}
SECTION(
"deserializeMsgPack() returns NoMemory of string has 65536 characters") {
"deserializeMsgPack() returns NoMemory if string has 65536 characters") {
auto input =
std::string("\xdb\x00\x01\x00\x00", 5) + std::string(65536, '?');
@ -54,4 +70,22 @@ TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 2") {
REQUIRE(err == DeserializationError::NoMemory);
}
SECTION("deserializeMsgPack() returns Ok if binary has 65535 characters") {
auto input = "\xc5\xff\xff" + std::string(65535, '?');
auto err = deserializeMsgPack(doc, input);
REQUIRE(err == DeserializationError::Ok);
}
SECTION(
"deserializeMsgPack() returns NoMemory of binary has 65536 characters") {
auto input =
std::string("\xc6\x00\x01\x00\x00", 5) + std::string(65536, '?');
auto err = deserializeMsgPack(doc, input);
REQUIRE(err == DeserializationError::NoMemory);
}
}