tst_QMap: avoid tripping MSVC debug-mode iterator assertions

It does a check to ensure you aren't comparing outside the container.

Fixes: QTBUG-106001
Change-Id: Ic6547f8247454b47baa8fffd170eef346b7f4f24
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit f039147165049dedcf6e1d92d902af28f566d753)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2022-08-26 12:38:40 -03:00 committed by Qt Cherry-pick Bot
parent e3de89533b
commit 8226ae9ac7

View File

@ -422,7 +422,12 @@ void tst_QMap::beginEnd()
// detach
map2.insert( "2", "c" );
QVERIFY( map.constBegin() == map.constBegin() );
QVERIFY( map.constBegin() != map2.constBegin() );
// comparing iterators between two different std::map is UB (and raises an
// assertion failure with MSVC debug-mode iterators), so we compare the
// elements' addresses.
QVERIFY(&map.constBegin().key() != &map2.constBegin().key());
QVERIFY(&map.constBegin().value() != &map2.constBegin().value());
}
void tst_QMap::firstLast()