Skip to content

Commit 81afc74

Browse files
authored
partial read nested array tests (#1506)
1 parent 3f3a813 commit 81afc74

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/json_test/json_test.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -8020,6 +8020,12 @@ suite nested_partial_read_tests = [] {
80208020
};
80218021
};
80228022

8023+
struct array_holder_t
8024+
{
8025+
std::vector<int> x{0, 0, 0, 0, 0};
8026+
std::vector<int> y{0};
8027+
};
8028+
80238029
suite nested_array_partial_read_tests = [] {
80248030
using namespace ut;
80258031

@@ -8035,6 +8041,20 @@ suite nested_array_partial_read_tests = [] {
80358041
expect(v[0][0] == 1);
80368042
expect(v[0][1] == 2);
80378043
};
8044+
8045+
"array_holder_t"_test = [] {
8046+
array_holder_t obj{};
8047+
std::string buf = R"({"x":[1,2,3],"y":[1,2,3,4]})";
8048+
8049+
auto ec = glz::read<partial_read>(obj, buf);
8050+
expect(not ec) << glz::format_error(ec, buf);
8051+
expect(obj.x.size() == 3);
8052+
expect(obj.x[0] == 1);
8053+
expect(obj.x[1] == 2);
8054+
expect(obj.x[2] == 3);
8055+
expect(obj.y.size() == 1);
8056+
expect(obj.y[0] == 1);
8057+
};
80388058
};
80398059

80408060
struct AccountUpdateInner

0 commit comments

Comments
 (0)