From 901a6e7986c1f6323eae8550f7085e4ba1513f20 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 12 Jun 2025 11:11:20 +0200 Subject: [PATCH] tst_ContainerApiSymmetry: ensure we're checking defined iterator types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old code used the same type of container for both target and source in the range-assign() test. This limits our test coverage. Fork the test to explicitly test with random-access (std::vector), as well as forward-only (std::forward_list) iterators. This ensures we have coverage of random-access, forward as well as the existing input iterator types. Amends 426d975cee9c783aec0832f376b836cdabee983f. Pick-to: 6.10 6.9 6.8 Change-Id: I59c7a322ecbcc564baa1263e02b234bc53563fac Reviewed-by: Ivan Solovev Reviewed-by: MÃ¥rten Nordheim --- .../tst_containerapisymmetry.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp index 0237f60c3ca..29b229637e3 100644 --- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp +++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp @@ -982,9 +982,23 @@ void tst_ContainerApiSymmetry::assign_impl() const QCOMPARE_EQ(c.capacity(), grownCapacity); } { - // range version for non input iterator + // range version for forward iterator auto c = make(4); - auto src = make(1); + auto src = std::forward_list(); + + src.assign(8, tData); + RET_CHECK(c.assign(src.begin(), src.end())); // may reallocate + CHECK(c, tData, c.size(), S(8)); + + const S oldCapacity = c.capacity(); + c.assign(src.begin(), src.begin()); + CHECK(c, tData, c.size(), S(0)); + QCOMPARE_EQ(c.capacity(), oldCapacity); + } + { + // range version for random-access iterator + auto c = make(4); + auto src = std::vector(); src.assign(8, tData); RET_CHECK(c.assign(src.begin(), src.end())); // may reallocate