Skip to content

Commit

Permalink
Add additional file_read test
Browse files Browse the repository at this point in the history
  • Loading branch information
mwalcott3 committed Mar 3, 2023
1 parent 202b642 commit 21bc431
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/glaze/json/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ namespace glz
first = false;
else [[likely]] {
match<','>(ctx, it);
skip_ws<Opts>(ctx, it, end);
}

if constexpr (glaze_object_t<T>) {
Expand Down
30 changes: 30 additions & 0 deletions tests/json_test/json_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,36 @@ suite macro_tests = [] {
};
};

struct file_struct
{
std::string name;
std::string label;

struct glaze
{
using T = file_struct;
static constexpr auto value = glz::object("name", &T::name, "label", &T::label);
};
};

suite read_file_test = [] {
std::string filename = "../file.json";
{
std::ofstream out(filename);
expect(bool(out));
if (out) {
out << R"({
"name": "my",
"label": "label"
})";
}
}

file_struct s;
expect(glz::read_file(s, filename) == glz::error_code::none);
};


struct includer_struct
{
std::string str = "Hello";
Expand Down

0 comments on commit 21bc431

Please sign in to comment.