mirror of
https://github.com/nlohmann/json.git
synced 2026-02-24 04:16:26 +00:00
BSON: support objects with int32 members
This commit is contained in:
@@ -231,6 +231,30 @@ TEST_CASE("BSON")
|
||||
CHECK(json::from_bson(result, true, false) == j);
|
||||
}
|
||||
|
||||
SECTION("non-empty object with integer (32-bit) member")
|
||||
{
|
||||
json j =
|
||||
{
|
||||
{ "entry", std::int32_t{0x12345678} }
|
||||
};
|
||||
|
||||
std::vector<uint8_t> expected =
|
||||
{
|
||||
0x10, 0x00, 0x00, 0x00, // size (little endian)
|
||||
0x10, /// entry: int32
|
||||
'e', 'n', 't', 'r', 'y', '\x00',
|
||||
0x78, 0x56, 0x34, 0x12,
|
||||
0x00 // end marker
|
||||
};
|
||||
|
||||
const auto result = json::to_bson(j);
|
||||
CHECK(result == expected);
|
||||
|
||||
// roundtrip
|
||||
CHECK(json::from_bson(result) == j);
|
||||
CHECK(json::from_bson(result, true, false) == j);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user