From 0843810d10f4162c14bf666ca681d1a765edfb30 Mon Sep 17 00:00:00 2001 From: raidgar98 Date: Fri, 23 Dec 2022 16:01:02 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20tests=20for=20array=20deseria?= =?UTF-8?q?lization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/json_deserial.test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/json_deserial.test.cpp b/tests/json_deserial.test.cpp index e98a97b..bf3db12 100644 --- a/tests/json_deserial.test.cpp +++ b/tests/json_deserial.test.cpp @@ -369,7 +369,25 @@ namespace }; "array"_test = [] { + adv_check_object_deserial(R"({"field_0": [1, 2, 3]})", [](const auto& lhs) { return lhs->field_0 == std::vector({1, 2, 3}); }); + adv_check_object_deserial(R"({"field_0": 2137, "field_1": [1, 2, 3]})", [](const auto& lhs) { + return lhs->field_0 == 2137 && lhs->field_1 == std::vector({1, 2, 3}); + }); + + adv_check_object_deserial(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(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