diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-19 10:12:22 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-19 22:12:04 +0200 |
commit | 45c248a011152727a7d7737e04ed721a01ad04bb (patch) | |
tree | 423647762d72774e24d38419ca0f3b8672247d11 /tests | |
parent | 37c7ef4f4a8478e94eaf0af5b40c279c476fa561 (diff) |
QAssociativeIterable: Add methods to add/remove keys and values
This way we can actually modify the container. Previously the interface
was rather useless.
Change-Id: I278aae46999862ada115c9066a010d7de5cde4ff
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 4ff404e12a..d3feabfac1 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -4355,6 +4355,16 @@ void testAssociativeIteration() else if (mappingIter.metaContainer().mappedMetaType() == QMetaType::fromType<bool>()) QCOMPARE(mappingIter.value(5).toBool(), true); + QVERIFY(mappingIter.containsKey("5")); + mappingIter.removeKey(QStringLiteral("5")); + QCOMPARE(mappingIter.find(5), mappingIter.end()); + + mappingIter.setValue(5, 44); + if (mappingIter.metaContainer().mappedMetaType() == QMetaType::fromType<int>()) + QCOMPARE(mappingIter.value(5).toInt(), 44); + else if (mappingIter.metaContainer().mappedMetaType() == QMetaType::fromType<bool>()) + QCOMPARE(mappingIter.value(5).toBool(), true); + // Test that find() does not coerce auto container = Container(); container[0] = true; |