summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-28 00:54:32 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-30 05:27:43 +0000
commit1127baf0bc3251c359ece39e0e23a7bb5531e4da (patch)
treeb3dbfd4767b6ac188a1b3150aacdfaf537ce8f1e /tests
parent487f7119670029ddbcffd1dd31c462e2db78c7b8 (diff)
QFlatMap: add full is_transparent support [3/3]: add overloads
Now add the missing overloads for mixed-type lookups, supported by is_transparent Compare objects. Change-Id: Ib588b6a4f733d5d9908c8c7d7c209df6e7bd6674 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 64bc6509c350c5750c6432a0ae6876f4bfb97cd0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp b/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp
index 1de1c3ad71..88d2748f06 100644
--- a/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp
+++ b/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp
@@ -410,7 +410,7 @@ void tst_QFlatMap::transparency()
struct StringViewCompare
{
using is_transparent = void;
- bool operator()(const QStringView &lhs, const QStringView &rhs) const
+ bool operator()(QAnyStringView lhs, QAnyStringView rhs) const
{
return lhs < rhs;
}
@@ -424,8 +424,21 @@ void tst_QFlatMap::transparency()
const QStringView sv2{numbers.constData() + 4, 3};
const QStringView sv3{numbers.constData() + 8, 5};
QCOMPARE(m.lower_bound(sv1).value(), "een");
+ QCOMPARE(m.value(sv1), "een");
QCOMPARE(m.lower_bound(sv2).value(), "twee");
+ QCOMPARE(m.value(sv2), "twee");
QCOMPARE(m.lower_bound(sv3).value(), "dree");
+ QCOMPARE(m.value(sv3), "dree");
+
+ QVERIFY(m.contains(sv2));
+ auto twee = m.take(sv2);
+ static_assert(std::is_same_v<decltype(twee), QString>);
+ QCOMPARE(twee, "twee");
+ QVERIFY(!m.contains(sv2));
+
+ QVERIFY(m.contains(QLatin1String("one")));
+ QVERIFY(m.remove(QAnyStringView(u8"one")));
+ QVERIFY(!m.contains(QLatin1String("one")));
}
void tst_QFlatMap::try_emplace_and_insert_or_assign()