From c928158d1607e998fc706cda46cc0021106be64c Mon Sep 17 00:00:00 2001 From: Patrick Urbanke Date: Thu, 18 Jan 2024 05:10:40 +0100 Subject: [PATCH] Made sure that the BSON tests run through --- include/rfl/bson/Writer.hpp | 19 ++++++++++--------- tests/bson/tests.cpp | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/rfl/bson/Writer.hpp b/include/rfl/bson/Writer.hpp index b3184ebb..92c78577 100644 --- a/include/rfl/bson/Writer.hpp +++ b/include/rfl/bson/Writer.hpp @@ -13,6 +13,7 @@ #include #include +#include "../Box.hpp" #include "../Ref.hpp" #include "../Result.hpp" #include "../always_false.hpp" @@ -102,20 +103,20 @@ class Writer { OutputObjectType add_object_to_array( const size_t _size, OutputArrayType* _parent) const noexcept { - subdocs_->push_back(BSONType{}); + subdocs_->emplace_back(rfl::Box()); bson_array_builder_append_document_begin(_parent->val_, - &subdocs_->back().val_); - return OutputObjectType(&subdocs_->back().val_, IsArray{_parent->val_}); + &(subdocs_->back()->val_)); + return OutputObjectType(&subdocs_->back()->val_, IsArray{_parent->val_}); } OutputObjectType add_object_to_object( const std::string& _name, const size_t _size, OutputObjectType* _parent) const noexcept { - subdocs_->push_back(BSONType{}); + subdocs_->emplace_back(rfl::Box()); bson_append_document_begin(_parent->val_, _name.c_str(), static_cast(_name.size()), - &subdocs_->back().val_); - return OutputObjectType(&subdocs_->back().val_, IsObject{_parent->val_}); + &(subdocs_->back()->val_)); + return OutputObjectType(&subdocs_->back()->val_, IsObject{_parent->val_}); } template @@ -131,7 +132,7 @@ class Writer { static_cast(_var)); } else if constexpr (std::is_integral>()) { bson_array_builder_append_int64(_parent->val_, - static_cast(_var)); + static_cast(_var)); } else { static_assert(rfl::always_false_v, "Unsupported type."); } @@ -155,7 +156,7 @@ class Writer { } else if constexpr (std::is_integral>()) { bson_append_int64(_parent->val_, _name.c_str(), static_cast(_name.size()), - static_cast(_var)); + static_cast(_var)); } else { static_assert(rfl::always_false_v, "Unsupported type."); } @@ -211,7 +212,7 @@ class Writer { bson_t* const doc_; /// Contain all of the subdocuments. - const rfl::Ref> subdocs_; + const rfl::Ref>> subdocs_; }; } // namespace bson diff --git a/tests/bson/tests.cpp b/tests/bson/tests.cpp index 96412af0..07067f88 100644 --- a/tests/bson/tests.cpp +++ b/tests/bson/tests.cpp @@ -37,7 +37,7 @@ int main() { test_enum::test(); test_flag_enum::test(); test_flag_enum_with_int::test(); - // test_map::test(); + test_map::test(); test_map_with_key_validation::test(); test_variant::test(); test_field_variant::test();