Added a test that removes an element during iteration (#1332)

This commit is contained in:
Benoit Blanchon
2020-07-30 09:20:31 +02:00
parent c63eb80b95
commit 4d7f03836c

View File

@ -65,4 +65,15 @@ TEST_CASE("JsonArray::remove()") {
REQUIRE(_array[0] == 1);
REQUIRE(_array[1] == 2);
}
SECTION("In a loop") {
for (JsonArray::iterator it = _array.begin(); it != _array.end(); ++it) {
if (*it == 2)
_array.remove(it);
}
REQUIRE(2 == _array.size());
REQUIRE(_array[0] == 1);
REQUIRE(_array[1] == 3);
}
}