mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-30 02:37:35 +02:00
MsgPack: test failing string allocation
This commit is contained in:
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "Allocators.hpp"
|
||||||
|
|
||||||
TEST_CASE("deserializeMsgPack() returns InvalidInput") {
|
TEST_CASE("deserializeMsgPack() returns InvalidInput") {
|
||||||
JsonDocument doc;
|
JsonDocument doc;
|
||||||
|
|
||||||
@ -228,3 +230,19 @@ TEST_CASE("deserializeMsgPack() replaces ext types by null") {
|
|||||||
20) == "[null,42]");
|
20) == "[null,42]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("bin 8") {
|
||||||
|
DeserializationError err = deserializeMsgPack(doc, "\xC4\x01X", 3);
|
||||||
|
REQUIRE(err == DeserializationError::NoMemory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user