tst_ContainerApiSymmetry: ensure we're checking defined iterator types

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 <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2025-06-12 11:11:20 +02:00
parent c51a038615
commit 901a6e7986

View File

@ -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<Container>(4);
auto src = make<Container>(1);
auto src = std::forward_list<V>();
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<Container>(4);
auto src = std::vector<V>();
src.assign(8, tData);
RET_CHECK(c.assign(src.begin(), src.end())); // may reallocate