Skip to content

Commit c928158

Browse files
Made sure that the BSON tests run through
1 parent a10ddf8 commit c928158

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

include/rfl/bson/Writer.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <variant>
1414
#include <vector>
1515

16+
#include "../Box.hpp"
1617
#include "../Ref.hpp"
1718
#include "../Result.hpp"
1819
#include "../always_false.hpp"
@@ -102,20 +103,20 @@ class Writer {
102103

103104
OutputObjectType add_object_to_array(
104105
const size_t _size, OutputArrayType* _parent) const noexcept {
105-
subdocs_->push_back(BSONType{});
106+
subdocs_->emplace_back(rfl::Box<BSONType>());
106107
bson_array_builder_append_document_begin(_parent->val_,
107-
&subdocs_->back().val_);
108-
return OutputObjectType(&subdocs_->back().val_, IsArray{_parent->val_});
108+
&(subdocs_->back()->val_));
109+
return OutputObjectType(&subdocs_->back()->val_, IsArray{_parent->val_});
109110
}
110111

111112
OutputObjectType add_object_to_object(
112113
const std::string& _name, const size_t _size,
113114
OutputObjectType* _parent) const noexcept {
114-
subdocs_->push_back(BSONType{});
115+
subdocs_->emplace_back(rfl::Box<BSONType>());
115116
bson_append_document_begin(_parent->val_, _name.c_str(),
116117
static_cast<int>(_name.size()),
117-
&subdocs_->back().val_);
118-
return OutputObjectType(&subdocs_->back().val_, IsObject{_parent->val_});
118+
&(subdocs_->back()->val_));
119+
return OutputObjectType(&subdocs_->back()->val_, IsObject{_parent->val_});
119120
}
120121

121122
template <class T>
@@ -131,7 +132,7 @@ class Writer {
131132
static_cast<double>(_var));
132133
} else if constexpr (std::is_integral<std::remove_cvref_t<T>>()) {
133134
bson_array_builder_append_int64(_parent->val_,
134-
static_cast<std::int32_t>(_var));
135+
static_cast<std::int64_t>(_var));
135136
} else {
136137
static_assert(rfl::always_false_v<T>, "Unsupported type.");
137138
}
@@ -155,7 +156,7 @@ class Writer {
155156
} else if constexpr (std::is_integral<std::remove_cvref_t<T>>()) {
156157
bson_append_int64(_parent->val_, _name.c_str(),
157158
static_cast<int>(_name.size()),
158-
static_cast<std::int32_t>(_var));
159+
static_cast<std::int64_t>(_var));
159160
} else {
160161
static_assert(rfl::always_false_v<T>, "Unsupported type.");
161162
}
@@ -211,7 +212,7 @@ class Writer {
211212
bson_t* const doc_;
212213

213214
/// Contain all of the subdocuments.
214-
const rfl::Ref<std::vector<BSONType>> subdocs_;
215+
const rfl::Ref<std::vector<rfl::Box<BSONType>>> subdocs_;
215216
};
216217

217218
} // namespace bson

tests/bson/tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main() {
3737
test_enum::test();
3838
test_flag_enum::test();
3939
test_flag_enum_with_int::test();
40-
// test_map::test();
40+
test_map::test();
4141
test_map_with_key_validation::test();
4242
test_variant::test();
4343
test_field_variant::test();

0 commit comments

Comments
 (0)