mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-17 04:22:18 +02:00
Added support for non zero-terminated strings (fixes #704)
This commit is contained in:
29
test/MsgPack/std_istream.cpp
Normal file
29
test/MsgPack/std_istream.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("deserializeMsgPack(std::istream&)") {
|
||||
DynamicJsonDocument doc;
|
||||
|
||||
SECTION("should accept a zero in input") {
|
||||
std::istringstream input(std::string("\x92\x00\x02", 3));
|
||||
|
||||
MsgPackError err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == MsgPackError::Ok);
|
||||
JsonArray& arr = doc.as<JsonArray>();
|
||||
REQUIRE(arr[0] == 0);
|
||||
REQUIRE(arr[1] == 2);
|
||||
}
|
||||
|
||||
SECTION("should detect incomplete input") {
|
||||
std::istringstream input("\x92\x00\x02");
|
||||
|
||||
MsgPackError err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == MsgPackError::IncompleteInput);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user