Skip to content

Commit

Permalink
🚑 fix for #492
Browse files Browse the repository at this point in the history
The original test case relied on an invalidated iterator. This error
did not occur before, but only with GCC with -D_GLIBCXX_DEBUG. This
commit fixes the test case. The library is unaffected by this change.
  • Loading branch information
nlohmann committed Mar 9, 2017
1 parent a135418 commit 758c4ad
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/src/unit-modifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,11 @@ TEST_CASE("modifiers")

SECTION("insert nothing (count = 0)")
{
auto pos = j_array.end();
auto it = j_array.insert(j_array.end(), 0, 5);
CHECK(j_array.size() == 4);
CHECK(it == pos);
// the returned iterator points to the first inserted element;
// there were 4 elements, so it should point to the 5th
CHECK(it == j_array.begin() + 4);
CHECK(j_array == json({1, 2, 3, 4}));
}
}
Expand Down

0 comments on commit 758c4ad

Please sign in to comment.