summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2009-04-30 10:29:48 +0200
committerhjk <qtc-committer@nokia.com>2009-04-30 10:29:48 +0200
commit7c8735b7715df8139646a13838f6f6750a56020b (patch)
treebd96ff157eba8e7c6ba4c1f117cd5c30538752ce /tests
parentfeb34c0e6fde4f04f04476054554a5fef75a32a4 (diff)
downloadqt-creator-7c8735b7715df8139646a13838f6f6750a56020b.tar.gz
Make QStringBuilder work with plain 'char' "chunks".
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmarks/qstringbuilder/main.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/tests/benchmarks/qstringbuilder/main.cpp b/tests/benchmarks/qstringbuilder/main.cpp
index 9b2bc99a7c..ba5cfe0a76 100644
--- a/tests/benchmarks/qstringbuilder/main.cpp
+++ b/tests/benchmarks/qstringbuilder/main.cpp
@@ -16,69 +16,91 @@ public:
private slots:
// QStringBuilder based
- void builderbased_l1literal_l1literal();
- void builderbased_l1literal_l1literal_l1literal();
- void builderbased_l1literal_l1literal_l1literal_l1literal();
+ void b_separator() { qDebug() << "\n------- QStringBuilder based ----------"; }
+ void b_2_l1literal();
+ void b_3_l1literal();
+ void b_4_l1literal();
+ void b_string_4_char();
// QString based for comparison
- void stringbased_l1string_l1string();
- void stringbased_l1string_l1string_l1string();
- void stringbased_l1string_l1string_l1string_l1string();
+ void s_separator() { qDebug() << "\n-------- QString based ---------"; }
+ void s_2_l1string();
+ void s_3_l1string();
+ void s_4_l1string();
+ void s_string_4_char();
private:
const QLatin1Literal l1literal;
const QLatin1String l1string;
+ const QString string;
+ const char achar;
};
tst_qstringbuilder::tst_qstringbuilder()
- : l1literal("some literal"), l1string("some literal")
+ : l1literal("some literal"),
+ l1string("some literal"),
+ string(l1string),
+ achar('c')
{}
-void tst_qstringbuilder::builderbased_l1literal_l1literal()
+void tst_qstringbuilder::b_2_l1literal()
{
QString result;
QBENCHMARK { result = l1literal % l1literal; }
QCOMPARE(result, l1string + l1string);
}
-void tst_qstringbuilder::builderbased_l1literal_l1literal_l1literal()
+void tst_qstringbuilder::b_3_l1literal()
{
QString result;
QBENCHMARK { result = l1literal % l1literal % l1literal; }
QCOMPARE(result, l1string + l1string + l1string);
}
-void tst_qstringbuilder::builderbased_l1literal_l1literal_l1literal_l1literal()
+void tst_qstringbuilder::b_4_l1literal()
{
QString result;
QBENCHMARK { result = l1literal % l1literal % l1literal % l1literal; }
QCOMPARE(result, l1string + l1string + l1string + l1string);
}
+void tst_qstringbuilder::b_string_4_char()
+{
+ QString result;
+ QBENCHMARK { result = string + achar + achar + achar; }
+ QCOMPARE(result, QString(string % achar % achar % achar));
+}
-void tst_qstringbuilder::stringbased_l1string_l1string()
+void tst_qstringbuilder::s_2_l1string()
{
QString result;
QBENCHMARK { result = l1string + l1string; }
QCOMPARE(result, QString(l1literal % l1literal));
}
-void tst_qstringbuilder::stringbased_l1string_l1string_l1string()
+void tst_qstringbuilder::s_3_l1string()
{
QString result;
QBENCHMARK { result = l1string + l1string + l1string; }
QCOMPARE(result, QString(l1literal % l1literal % l1literal));
}
-void tst_qstringbuilder::stringbased_l1string_l1string_l1string_l1string()
+void tst_qstringbuilder::s_4_l1string()
{
QString result;
QBENCHMARK { result = l1string + l1string + l1string + l1string; }
QCOMPARE(result, QString(l1literal % l1literal % l1literal % l1literal));
}
+void tst_qstringbuilder::s_string_4_char()
+{
+ QString result;
+ QBENCHMARK { result = string + achar + achar + achar; }
+ QCOMPARE(result, QString(string % achar % achar % achar));
+}
+
QTEST_MAIN(tst_qstringbuilder)
#include "main.moc"