Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenberry committed Jan 4, 2025
1 parent 752515f commit ac09e84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/glaze/core/wrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace glz
return [](auto&& v) { return custom_t{v, From, To}; };
}
}

// When reading into an array that is appendable, the new data will be appended rather than overwrite
template <auto MemPtr>
constexpr auto append_arrays = detail::opts_wrapper<MemPtr, &opts::append_arrays>();
Expand Down
3 changes: 1 addition & 2 deletions include/glaze/json/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,7 @@ namespace glz
const size_t ws_size = size_t(it - ws_start);

static constexpr bool should_append = resizable<T> && Opts.append_arrays;
if constexpr (not should_append)
{
if constexpr (not should_append) {
const auto n = value.size();

auto value_it = value.begin();
Expand Down
18 changes: 9 additions & 9 deletions tests/json_test/json_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10159,29 +10159,29 @@ suite append_arrays_tests = [] {
std::vector<int> v{};
constexpr glz::opts append_opts{.append_arrays = true};
expect(not glz::read<append_opts>(v, "[1,2,3]"));
expect(v == std::vector<int>{1,2,3});
expect(v == std::vector<int>{1, 2, 3});
expect(not glz::read<append_opts>(v, "[4,5,6]"));
expect(v == std::vector<int>{1,2,3,4,5,6});
expect(v == std::vector<int>{1, 2, 3, 4, 5, 6});
};

"append_arrays deque"_test = [] {
std::deque<int> v{};
constexpr glz::opts append_opts{.append_arrays = true};
expect(not glz::read<append_opts>(v, "[1,2,3]"));
expect(v == std::deque<int>{1,2,3});
expect(v == std::deque<int>{1, 2, 3});
expect(not glz::read<append_opts>(v, "[4,5,6]"));
expect(v == std::deque<int>{1,2,3,4,5,6});
expect(v == std::deque<int>{1, 2, 3, 4, 5, 6});
};

"append_arrays append_obj"_test = [] {
append_obj obj{};
expect(not glz::read_json(obj, R"({"names":["Bob"],"arrays":[[0,0]]})"));
expect(obj.names == std::vector<std::string>{"Bob"});
expect(obj.arrays == std::vector<std::array<int, 2>>{{0,0}});
expect(obj.arrays == std::vector<std::array<int, 2>>{{0, 0}});

expect(not glz::read_json(obj, R"({"names":["Liz"],"arrays":[[1,1]]})"));
expect(obj.names == std::vector<std::string>{"Bob", "Liz"});
expect(obj.arrays == std::vector<std::array<int, 2>>{{0,0},{1,1}});
expect(obj.arrays == std::vector<std::array<int, 2>>{{0, 0}, {1, 1}});
};
};

Expand Down

0 comments on commit ac09e84

Please sign in to comment.