Add a test using lots of similar strings.
authorRobin Burchell <robin+qt@viroteck.net>
Tue, 28 Feb 2012 19:49:19 +0000 (20:49 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 29 Feb 2012 21:39:00 +0000 (22:39 +0100)
This attempts to emulate a dictionary usecase of sorts, done in code to avoid
bloating the git repository by adding an actual word list.

Change-Id: I878bc4af8877ba780ee699932f240c0d9c8ff12c
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
tests/benchmarks/corelib/tools/qhash/main.cpp

index 18138cb..db33200 100644 (file)
@@ -67,6 +67,8 @@ private:
 
 ///////////////////// QHash /////////////////////
 
+#include <QDebug>
+
 void tst_QHash::data()
 {
     QTest::addColumn<QStringList>("items");
@@ -99,6 +101,40 @@ void tst_QHash::data()
         QTest::newRow("uuids-list") << uuids;
     }
 
+    {
+        // lots of strings with alphabetical characters, vaguely reminiscent of
+        // a dictionary.
+        //
+        // this programatically generates a series like:
+        //  AAAAAA
+        //  AAAAAB
+        //  AAAAAC
+        //  ...
+        //  AAAAAZ
+        //  AAAABZ
+        //  ...
+        //  AAAAZZ
+        //  AAABZZ
+        QByteArray id("AAAAAAA");
+        static QStringList dict;
+
+        if (dict.isEmpty()) {
+            for (int i = id.length() - 1; i > 0;) {
+                dict.append(id);
+                char c = id.at(i);
+                id[i] = ++c;
+
+                if (c == 'Z') {
+                    // wrap to next digit
+                    i--;
+                    id[i] = 'A';
+                }
+            }
+        }
+
+        QTest::newRow("dictionary") << dict;
+    }
+
 }
 
 void tst_QHash::qhash_qt4()