void tst_QQmlPropertyMap::count() { QQmlPropertyMap map; QCOMPARE(map.isEmpty(), true); map.insert(QLatin1String("key1"),100); map.insert(QLatin1String("key2"),200); QCOMPARE(map.count(), 2); QCOMPARE(map.isEmpty(), false); map.insert(QLatin1String("key3"),"Hello World"); QCOMPARE(map.count(), 3); //clearing doesn't remove the key map.clear(QLatin1String("key3")); QCOMPARE(map.count(), 3); QCOMPARE(map.size(), map.count()); }
void tst_QQmlPropertyMap::operatorValue() { QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); map.insert(QLatin1String("key2"),200); QVERIFY(map.count() == 2); QVERIFY(map.contains(QLatin1String("key1"))); const QQmlPropertyMap &constMap = map; QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100)); QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200)); QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1"))); QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2"))); }