From b5a05e1121ff4e47297234e02f7a1962d1e57179 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 2 Aug 2015 21:27:02 +0200 Subject: [PATCH] add a test for the iterator_wrapper --- test/unit.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/unit.cpp b/test/unit.cpp index 735fbd245..63c1e6f33 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -7547,6 +7547,24 @@ TEST_CASE("iterator class") } } +TEST_CASE("iterator_wrapper") +{ + SECTION("objects") + { + json j_object = {{"key1", 1}, {"key2", 2}}; + for (auto it : json::iterator_wrapper(j_object)) + { + CHECK((it.first == "key1" or it.first == "key2")); + CHECK((it.key() == "key1" or it.key() == "key2")); + CHECK(it.key() == it.first); + + CHECK((it.second == json(1) or it.second == json(2))); + CHECK((it.value() == json(1) or it.value() == json(2))); + CHECK(it.value() == it.second); + } + } +} + TEST_CASE("const_iterator class") { SECTION("construction")