mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-11-01 07:01:37 +01:00
Add support for MsgPack extension
This commit is contained in:
@@ -41,6 +41,24 @@ TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 1") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set(MsgPackExtension)") {
|
||||
SECTION("returns true if size <= 252") {
|
||||
auto str = std::string(252, '?');
|
||||
auto result = doc.set(MsgPackExtension(1, str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if size >= 253") {
|
||||
auto str = std::string(253, '?');
|
||||
auto result = doc.set(MsgPackExtension(1, str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeJson()") {
|
||||
SECTION("returns Ok if string length <= 255") {
|
||||
auto input = "\"" + std::string(255, '?') + "\"";
|
||||
@@ -91,5 +109,21 @@ TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 1") {
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
SECTION("returns Ok if extension size <= 252") {
|
||||
auto input = "\xc7\xfc\x01" + std::string(252, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if binary size >= 253") {
|
||||
auto input = "\xc7\xfd\x01" + std::string(253, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user