Skip to content

Commit

Permalink
✅ Add tests for array deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
raidgar98 committed Dec 23, 2022
1 parent ac709a2 commit 0843810
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/json_deserial.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,25 @@ namespace
};

"array"_test = [] {
adv_check_object_deserial<array::test_array_01_packed>(R"({"field_0": [1, 2, 3]})", [](const auto& lhs) { return lhs->field_0 == std::vector<int>({1, 2, 3}); });

adv_check_object_deserial<array::test_array_02_packed>(R"({"field_0": 2137, "field_1": [1, 2, 3]})", [](const auto& lhs) {
return lhs->field_0 == 2137 && lhs->field_1 == std::vector<int>({1, 2, 3});
});

adv_check_object_deserial<array::test_array_03_packed>(R"({"field_0": [{"field_0": 1}, {"field_0": 2}, {"field_0": 3}]})", [](const auto& lhs) {
int i = 1;
for(const auto& x: lhs->field_0)
if(x.field_0 != i++) return false;
return true;
});

adv_check_object_deserial<array::test_array_04_packed>(R"({"field_0": 2137, "field_1": [{"field_0": 1}, {"field_0": 2}, {"field_0": 3}]})", [](const auto& lhs) {
int i = 1;
for(const auto& x: lhs->field_1)
if(x.field_0 != i++) return false;
return lhs->field_0 == 2137;
});
};
};
} // namespace

0 comments on commit 0843810

Please sign in to comment.