diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-10-07 07:55:11 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-10-07 07:55:11 (GMT) |
commit | 087b624c616bc1b3dbe850a74d0737fffc08bec2 (patch) | |
tree | b362c857f8dff3742277e2d8d5af604432d0f988 /tests | |
parent | 8b7e766aa42739df8998ec9c1e94087b965ac87b (diff) | |
download | Qt-087b624c616bc1b3dbe850a74d0737fffc08bec2.zip Qt-087b624c616bc1b3dbe850a74d0737fffc08bec2.tar.gz Qt-087b624c616bc1b3dbe850a74d0737fffc08bec2.tar.bz2 |
implement qHash function for QScriptString
Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qscriptstring/tst_qscriptstring.cpp | 17 |
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" |