QHash: fix key() test
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Fri, 13 Apr 2012 18:41:47 +0000 (19:41 +0100)
committerQt by Nokia <qt-info@nokia.com>
Sat, 14 Apr 2012 11:51:49 +0000 (13:51 +0200)
The key returned by QHash::key is an arbitrary one that maps to the
given value. The test instead relied on it being a specific one.

Change-Id: I090351797e8b52036d78160fd810518a11e8107d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
tests/auto/corelib/tools/qhash/tst_qhash.cpp

index 9d18c7a..5bd13b2 100644 (file)
@@ -526,14 +526,14 @@ void tst_QHash::key()
         hash2.insert(3, "two");
         QCOMPARE(hash2.key("one"), 1);
         QCOMPARE(hash2.key("one", def), 1);
-        QCOMPARE(hash2.key("two"), 2);
-        QCOMPARE(hash2.key("two", def), 2);
+        QVERIFY(hash2.key("two") == 2 || hash2.key("two") == 3);
+        QVERIFY(hash2.key("two", def) == 2 || hash2.key("two", def) == 3);
         QCOMPARE(hash2.key("three"), 0);
         QCOMPARE(hash2.key("three", def), def);
 
         hash2.insert(-1, "two");
-        QCOMPARE(hash2.key("two"), -1);
-        QCOMPARE(hash2.key("two", def), -1);
+        QVERIFY(hash2.key("two") == 2 || hash2.key("two") == 3 || hash2.key("two") == -1);
+        QVERIFY(hash2.key("two", def) == 2 || hash2.key("two", def) == 3 || hash2.key("two", def) == -1);
 
         hash2.insert(0, "zero");
         QCOMPARE(hash2.key("zero"), 0);