@@ -346,7 +346,7 @@ struct Thing
346
346
std::map<int, double> mapi{{5, 3.14}, {7, 7.42}, {2, 9.63}};
347
347
sub_thing* thing_ptr{};
348
348
349
- Thing() : thing_ptr(&thing){};
349
+ Thing() : thing_ptr(&thing) {};
350
350
};
351
351
352
352
template <>
@@ -4197,7 +4197,7 @@ struct glz::meta<cat>
4197
4197
4198
4198
struct person
4199
4199
{
4200
- void eat(const std::string&){};
4200
+ void eat(const std::string&) {};
4201
4201
};
4202
4202
4203
4203
template <>
@@ -6155,11 +6155,8 @@ suite char_buffer = [] {
6155
6155
static_assert(!glz::detail::char_array_t<char*>);
6156
6156
6157
6157
suite enum_map = [] {
6158
- "enum map"_test = [] {
6159
- std::map<Color, std::string> color_map;
6160
- color_map[Color::Red] = "red";
6161
- color_map[Color::Green] = "green";
6162
- color_map[Color::Blue] = "blue";
6158
+ "enum map key"_test = [] {
6159
+ std::map<Color, std::string> color_map{{Color::Red, "red"}, {Color::Green, "green"}, {Color::Blue, "blue"}};
6163
6160
6164
6161
std::string s{};
6165
6162
expect(not glz::write_json(color_map, s));
@@ -6172,6 +6169,48 @@ suite enum_map = [] {
6172
6169
expect(color_map.at(Color::Green) == "green");
6173
6170
expect(color_map.at(Color::Blue) == "blue");
6174
6171
};
6172
+
6173
+ "enum map key vector pair concatenate"_test = [] {
6174
+ std::vector<std::pair<Color, std::string>> colors{
6175
+ {Color::Red, "red"}, {Color::Green, "green"}, {Color::Blue, "blue"}};
6176
+
6177
+ std::string s{};
6178
+ expect(not glz::write_json(colors, s));
6179
+
6180
+ expect(s == R"({"Red":"red","Green":"green","Blue":"blue"})");
6181
+
6182
+ auto expected = colors;
6183
+ colors.clear();
6184
+ expect(!glz::read_json(colors, s));
6185
+ expect(colors == expected);
6186
+ };
6187
+
6188
+ "enum map value"_test = [] {
6189
+ std::map<int, Color> color_map{{0, Color::Red}, {1, Color::Green}, {2, Color::Blue}};
6190
+
6191
+ std::string s{};
6192
+ expect(not glz::write_json(color_map, s));
6193
+
6194
+ expect(s == R"({"0":"Red","1":"Green","2":"Blue"})");
6195
+
6196
+ auto expectedMap = color_map;
6197
+ color_map.clear();
6198
+ expect(!glz::read_json(color_map, s));
6199
+ expect(expectedMap == color_map);
6200
+ };
6201
+
6202
+ "enum map value vector pair concatenate"_test = [] {
6203
+ std::vector<std::pair<int, Color>> colors{{0, Color::Red}, {1, Color::Green}, {2, Color::Blue}};
6204
+
6205
+ std::string s{};
6206
+ expect(not glz::write_json(colors, s));
6207
+ expect(s == R"({"0":"Red","1":"Green","2":"Blue"})");
6208
+
6209
+ auto expected = colors;
6210
+ colors.clear();
6211
+ expect(!glz::read_json(colors, s));
6212
+ expect(colors == expected);
6213
+ };
6175
6214
};
6176
6215
6177
6216
suite obj_handling = [] {
@@ -6419,9 +6458,8 @@ template <>
6419
6458
struct glz::meta<test_mapping_t>
6420
6459
{
6421
6460
using T = test_mapping_t;
6422
- static constexpr auto value = object("id", &T::id, "coordinates", [](auto& self) {
6423
- return coordinates_t{&self.latitude, &self.longitude};
6424
- });
6461
+ static constexpr auto value =
6462
+ object("id", &T::id, "coordinates", [](auto& self) { return coordinates_t{&self.latitude, &self.longitude}; });
6425
6463
};
6426
6464
6427
6465
suite mapping_struct = [] {
@@ -9699,8 +9737,8 @@ template <class V>
9699
9737
struct glz::meta<response_t<V>>
9700
9738
{
9701
9739
using T = response_t<V>;
9702
- static constexpr auto value = object(
9703
- "result", [](auto& s) -> auto& { return s.result; }, "id", &T::id, "error", &T::error);
9740
+ static constexpr auto value =
9741
+ object( "result", [](auto& s) -> auto& { return s.result; }, "id", &T::id, "error", &T::error);
9704
9742
};
9705
9743
9706
9744
template <>
@@ -9919,7 +9957,7 @@ namespace trr
9919
9957
9920
9958
struct Person
9921
9959
{
9922
- Person(Address* const p_add) : p_add(p_add){};
9960
+ Person(Address* const p_add) : p_add(p_add) {};
9923
9961
std::string name;
9924
9962
Address* const p_add; // pointer is const, Address object is mutable
9925
9963
};
0 commit comments