From 758c4addc1c6a010a3e9f3730419f9dfae9cd769 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 9 Mar 2017 18:20:26 +0100 Subject: [PATCH] :ambulance: fix for #492 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. --- test/src/unit-modifiers.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/src/unit-modifiers.cpp b/test/src/unit-modifiers.cpp index 0edc9a12..2b5fdd71 100644 --- a/test/src/unit-modifiers.cpp +++ b/test/src/unit-modifiers.cpp @@ -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})); } }