Implement MsgPackBinary using raw strings and converters

This commit is contained in:
Benoit Blanchon
2024-05-01 19:27:23 +02:00
parent 002b07f0c5
commit 2c670e0148
12 changed files with 130 additions and 133 deletions

View File

@ -21,16 +21,16 @@ 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, '?');
SECTION("set() returns true if string has 65532 characters") {
auto str = std::string(65532, '?');
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, '?');
SECTION("set() returns false if string has 65533 characters") {
auto str = std::string(65533, '?');
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
REQUIRE(result == false);
@ -71,8 +71,8 @@ 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, '?');
SECTION("deserializeMsgPack() returns Ok if binary has 65532 characters") {
auto input = "\xc5\xff\xfc" + std::string(65532, '?');
auto err = deserializeMsgPack(doc, input);
@ -80,9 +80,8 @@ TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 2") {
}
SECTION(
"deserializeMsgPack() returns NoMemory of binary has 65536 characters") {
auto input =
std::string("\xc6\x00\x01\x00\x00", 5) + std::string(65536, '?');
"deserializeMsgPack() returns NoMemory of binary has 65534 characters") {
auto input = "\xc5\xff\xfd" + std::string(65534, '?');
auto err = deserializeMsgPack(doc, input);