summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptstring/tst_qscriptstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qscriptstring/tst_qscriptstring.cpp')
-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"