summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptstring
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-10-07 07:55:11 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-10-07 07:55:11 (GMT)
commit087b624c616bc1b3dbe850a74d0737fffc08bec2 (patch)
treeb362c857f8dff3742277e2d8d5af604432d0f988 /tests/auto/qscriptstring
parent8b7e766aa42739df8998ec9c1e94087b965ac87b (diff)
downloadQt-087b624c616bc1b3dbe850a74d0737fffc08bec2.zip
Qt-087b624c616bc1b3dbe850a74d0737fffc08bec2.tar.gz
Qt-087b624c616bc1b3dbe850a74d0737fffc08bec2.tar.bz2
implement qHash function for QScriptString
Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests/auto/qscriptstring')
-rw-r--r--tests/auto/qscriptstring/tst_qscriptstring.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qscriptstring/tst_qscriptstring.cpp b/tests/auto/qscriptstring/tst_qscriptstring.cpp
index 0968b61..e1a4bc1 100644
--- a/tests/auto/qscriptstring/tst_qscriptstring.cpp
+++ b/tests/auto/qscriptstring/tst_qscriptstring.cpp
@@ -58,6 +58,7 @@ public:
private slots:
void test();
+ void hash();
};
tst_QScriptString::tst_QScriptString()
@@ -138,5 +139,21 @@ void tst_QScriptString::test()
}
}
+void tst_QScriptString::hash()
+{
+ QScriptEngine engine;
+ QHash<QScriptString, int> stringToInt;
+ QScriptString foo = engine.toStringHandle("foo");
+ QScriptString bar = engine.toStringHandle("bar");
+ QVERIFY(!stringToInt.contains(foo));
+ for (int i = 0; i < 1000000; ++i)
+ stringToInt.insert(foo, 123);
+ QCOMPARE(stringToInt.value(foo), 123);
+ QVERIFY(!stringToInt.contains(bar));
+ stringToInt.insert(bar, 456);
+ QCOMPARE(stringToInt.value(bar), 456);
+ QCOMPARE(stringToInt.value(foo), 123);
+}
+
QTEST_MAIN(tst_QScriptString)
#include "tst_qscriptstring.moc"