diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 3c3e0ba1e9..689202346c 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -23,6 +23,7 @@ private slots: void insert(); void insertMany(); + void insertDuplicate(); void operatorInsert(); void operatorValue(); void clear(); @@ -191,6 +192,34 @@ void tst_QQmlPropertyMap::insertMany() QCOMPARE(map.value(QStringLiteral("key1")).toInt(), 100); } +void tst_QQmlPropertyMap::insertDuplicate() +{ + QHash values; + values.insert(QLatin1String("key2"), 200); + values.insert(QLatin1String("key1"), "Hello World"); + + auto expectedCount = values.count(); + + QQmlPropertyMap map; + map.insert(values); + QCOMPARE(map.keys().size(), expectedCount); + + map.insert(QStringLiteral("key2"), 24); + QCOMPARE(map.keys().size(), expectedCount); + QCOMPARE(map.value(QStringLiteral("key2")).toInt(), 24); + + map.insert(QString(), QVariant("Empty1")); + QCOMPARE(map.keys().size(), ++expectedCount); + map.insert(QString(), QVariant("Empty2")); + QCOMPARE(map.keys().size(), expectedCount); + + QHash emptyKeyMap; + emptyKeyMap.insert(QString(), 200); + emptyKeyMap.insert(QString(), 400); + map.insert(emptyKeyMap); + QCOMPARE(map.keys().size(), expectedCount); +} + void tst_QQmlPropertyMap::operatorInsert() { QQmlPropertyMap map;