mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-17 20:42:24 +02:00
Merged MsgPackError and JsonError into DeserializationError.
Return NotSupported if the JSON input contains "\u".
This commit is contained in:
@ -11,32 +11,34 @@ TEST_CASE("deserializeMsgPack(const std::string&)") {
|
||||
SECTION("should accept const string") {
|
||||
const std::string input("\x92\x01\x02");
|
||||
|
||||
MsgPackError err = deserializeMsgPack(doc, input);
|
||||
DeserializationError err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == MsgPackError::Ok);
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("should accept temporary string") {
|
||||
MsgPackError err = deserializeMsgPack(doc, std::string("\x92\x01\x02"));
|
||||
DeserializationError err =
|
||||
deserializeMsgPack(doc, std::string("\x92\x01\x02"));
|
||||
|
||||
REQUIRE(err == MsgPackError::Ok);
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("should duplicate content") {
|
||||
std::string input("\x91\xA5hello");
|
||||
|
||||
MsgPackError err = deserializeMsgPack(doc, input);
|
||||
DeserializationError err = deserializeMsgPack(doc, input);
|
||||
input[2] = 'X'; // alter the string tomake sure we made a copy
|
||||
|
||||
JsonArray& array = doc.as<JsonArray>();
|
||||
REQUIRE(err == MsgPackError::Ok);
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(std::string("hello") == array[0]);
|
||||
}
|
||||
|
||||
SECTION("should accept a zero in input") {
|
||||
MsgPackError err = deserializeMsgPack(doc, std::string("\x92\x00\x02", 3));
|
||||
DeserializationError err =
|
||||
deserializeMsgPack(doc, std::string("\x92\x00\x02", 3));
|
||||
|
||||
REQUIRE(err == MsgPackError::Ok);
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
JsonArray& arr = doc.as<JsonArray>();
|
||||
REQUIRE(arr[0] == 0);
|
||||
REQUIRE(arr[1] == 2);
|
||||
|
Reference in New Issue
Block a user