summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-05-18 18:38:25 +0200
committerQt by Nokia <qt-info@nokia.com>2012-09-03 13:41:55 +0200
commit68e04c3ac148bcbe71f2deeb7288563f6cdbcab5 (patch)
tree79970daa0b1b7e6393653a5363a6883f4896e66c /tests
parent64a8c78538275b8dbb9d2cbbb1f7b06b247fbe6b (diff)
QStringList::join: add an overload taking a single QChar
This overload avoids the needless heap allocation that the traditional overload incurs due to the implicit QChar -> QString conversion involved there. In order to share the implementation between the two overloads, QStringList_join now takes the separator as a (Char*,int) tuple instead of as a QString. Change-Id: I92961f13a3f19099de2a6e2df9f4789a12fc83a0 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
index 16a329f1dd..0f0fa75bc3 100644
--- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
+++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp
@@ -66,6 +66,8 @@ private slots:
void join() const;
void join_data() const;
void joinEmptiness() const;
+ void joinChar() const;
+ void joinChar_data() const;
void initializeList() const;
};
@@ -362,6 +364,42 @@ void tst_QStringList::join_data() const
<< QString("a b c");
}
+void tst_QStringList::joinChar() const
+{
+ QFETCH(QStringList, input);
+ QFETCH(QChar, separator);
+ QFETCH(QString, expectedResult);
+
+ QCOMPARE(input.join(separator), expectedResult);
+}
+
+void tst_QStringList::joinChar_data() const
+{
+ QTest::addColumn<QStringList>("input");
+ QTest::addColumn<QChar>("separator");
+ QTest::addColumn<QString>("expectedResult");
+
+ QTest::newRow("data1")
+ << QStringList()
+ << QChar(QLatin1Char(' '))
+ << QString();
+
+ QTest::newRow("data5")
+ << (QStringList()
+ << QLatin1String("a")
+ << QLatin1String("b"))
+ << QChar(QLatin1Char(' '))
+ << QString("a b");
+
+ QTest::newRow("data6")
+ << (QStringList()
+ << QLatin1String("a")
+ << QLatin1String("b")
+ << QLatin1String("c"))
+ << QChar(QLatin1Char(' '))
+ << QString("a b c");
+}
+
void tst_QStringList::joinEmptiness() const
{
QStringList list;