// ArduinoJson - https://arduinojson.org // Copyright Benoit Blanchon 2014-2021 // MIT License #include #include template static void run_iterator_test() { StaticJsonDocument doc; JsonArray tmp = doc.to(); tmp.add(12); tmp.add(34); TArray array = tmp; typename TArray::iterator it = array.begin(); typename TArray::iterator end = array.end(); REQUIRE(end != it); REQUIRE(12 == it->template as()); REQUIRE(12 == static_cast(*it)); ++it; REQUIRE(end != it); REQUIRE(34 == it->template as()); REQUIRE(34 == static_cast(*it)); ++it; REQUIRE(end == it); } TEST_CASE("JsonArray::begin()/end()") { SECTION("Non null JsonArray") { run_iterator_test(); } SECTION("Null JsonArray") { JsonArray array; REQUIRE(array.begin() == array.end()); } } TEST_CASE("JsonArrayConst::begin()/end()") { SECTION("Non null JsonArrayConst") { run_iterator_test(); } SECTION("Null JsonArrayConst") { JsonArrayConst array; REQUIRE(array.begin() == array.end()); } }