✨ binary formats can be stored in std::string, std::ofstreams or std::ostringstream #477
This commit is contained in:
parent
c136b6f200
commit
5851daa576
3 changed files with 109 additions and 61 deletions
|
|
@ -1284,6 +1284,25 @@ TEST_CASE("single CBOR roundtrip")
|
|||
// compare parsed JSON values
|
||||
CHECK(j1 == j2);
|
||||
|
||||
SECTION("roundtrips")
|
||||
{
|
||||
SECTION("std::ostringstream")
|
||||
{
|
||||
std::ostringstream ss;
|
||||
json::to_cbor(j1, ss);
|
||||
json j3 = json::from_cbor(ss.str());
|
||||
CHECK(j1 == j3);
|
||||
}
|
||||
|
||||
SECTION("std::string")
|
||||
{
|
||||
std::string s;
|
||||
json::to_cbor(j1, s);
|
||||
json j3 = json::from_cbor(s);
|
||||
CHECK(j1 == j3);
|
||||
}
|
||||
}
|
||||
|
||||
// check with different start index
|
||||
packed.insert(packed.begin(), 5, 0xff);
|
||||
CHECK(j1 == json::from_cbor(packed, 5));
|
||||
|
|
|
|||
|
|
@ -1126,6 +1126,25 @@ TEST_CASE("single MessagePack roundtrip")
|
|||
// compare parsed JSON values
|
||||
CHECK(j1 == j2);
|
||||
|
||||
SECTION("roundtrips")
|
||||
{
|
||||
SECTION("std::ostringstream")
|
||||
{
|
||||
std::ostringstream ss;
|
||||
json::to_msgpack(j1, ss);
|
||||
json j3 = json::from_msgpack(ss.str());
|
||||
CHECK(j1 == j3);
|
||||
}
|
||||
|
||||
SECTION("std::string")
|
||||
{
|
||||
std::string s;
|
||||
json::to_msgpack(j1, s);
|
||||
json j3 = json::from_msgpack(s);
|
||||
CHECK(j1 == j3);
|
||||
}
|
||||
}
|
||||
|
||||
// check with different start index
|
||||
packed.insert(packed.begin(), 5, 0xff);
|
||||
CHECK(j1 == json::from_msgpack(packed, 5));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue