BSON: Support for arrays
This commit is contained in:
parent
120d1d77d4
commit
cf485c2907
4 changed files with 154 additions and 21 deletions
|
@ -354,7 +354,6 @@ TEST_CASE("BSON")
|
|||
|
||||
SECTION("non-empty object with object member")
|
||||
{
|
||||
// directly encoding uint64 is not supported in bson (only for timestamp values)
|
||||
json j =
|
||||
{
|
||||
{ "entry", json::object() }
|
||||
|
@ -381,6 +380,34 @@ TEST_CASE("BSON")
|
|||
CHECK(json::from_bson(result, true, false) == j);
|
||||
}
|
||||
|
||||
SECTION("non-empty object with array member")
|
||||
{
|
||||
json j =
|
||||
{
|
||||
{ "entry", json::array() }
|
||||
};
|
||||
|
||||
std::vector<uint8_t> expected =
|
||||
{
|
||||
0x11, 0x00, 0x00, 0x00, // size (little endian)
|
||||
0x04, /// entry: embedded document
|
||||
'e', 'n', 't', 'r', 'y', '\x00',
|
||||
|
||||
0x05, 0x00, 0x00, 0x00, // size (little endian)
|
||||
// no entries
|
||||
0x00, // end marker (embedded document)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
SECTION("Some more complex document")
|
||||
{
|
||||
// directly encoding uint64 is not supported in bson (only for timestamp values)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue