From 456f721917d07b3dd4259c324ff216f90bd32139 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 20 Oct 2015 10:08:39 +0200 Subject: [PATCH] tests/auto/corelib: Remove some placeholder formatting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QByteArray/QString addition instead in loops and for test row names. Change-Id: Ieffb429efdc14aa5932b3fcdef5a18e13a62d35f Reviewed-by: Jędrzej Nowacki --- .../io/qdatastream/tst_qdatastream.cpp | 4 +-- tests/auto/corelib/io/qdir/tst_qdir.cpp | 2 +- .../tst_qfilesystemwatcher.cpp | 5 +-- .../auto/corelib/io/qnodebug/tst_qnodebug.cpp | 5 +-- .../corelib/io/qsettings/tst_qsettings.cpp | 2 +- tests/auto/corelib/io/qurl/tst_qurl.cpp | 6 ++-- .../tst_qabstractitemmodel.cpp | 3 +- .../tst_qidentityproxymodel.cpp | 4 +-- .../itemmodels/qitemmodel/modelstotest.cpp | 11 ++++--- .../tst_qitemselectionmodel.cpp | 31 ++++++++++--------- .../tst_qsortfilterproxymodel.cpp | 27 ++++++++-------- .../kernel/qmetatype/tst_qmetatype.cpp | 5 ++- .../qsharedmemory/test/tst_qsharedmemory.cpp | 2 +- .../qpluginloader/tst_qpluginloader.cpp | 6 ++-- .../tools/qbytearray/tst_qbytearray.cpp | 8 ++--- tests/auto/corelib/tools/qchar/tst_qchar.cpp | 22 +++++++------ .../corelib/tools/qdatetime/tst_qdatetime.cpp | 10 +++--- tests/auto/corelib/tools/qline/tst_qline.cpp | 6 ++-- .../corelib/tools/qlocale/tst_qlocale.cpp | 8 +++-- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 2 +- .../corelib/tools/qregexp/tst_qregexp.cpp | 6 ++-- .../tst_qregularexpression.cpp | 12 +++---- .../tools/qringbuffer/tst_qringbuffer.cpp | 2 +- .../corelib/tools/qstring/tst_qstring.cpp | 2 +- .../tools/qstringref/tst_qstringref.cpp | 14 ++++----- .../tst_qtextboundaryfinder.cpp | 4 +-- .../corelib/tools/qvector/tst_qvector.cpp | 4 ++- .../corelib/xml/qxmlstream/tst_qxmlstream.cpp | 23 ++++++++------ 28 files changed, 132 insertions(+), 104 deletions(-) diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index 39c9455b39..729cf6547e 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -340,7 +340,7 @@ void tst_QDataStream::stream_data(int noOfElements) QString tag = device + QLatin1Char('_') + byte_order; for (int e=0; e= 'A'); diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 026743257c..e8bbaa1b25 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -731,9 +731,10 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved() QString movePath = testDir.filePath("movehere"); for (int i = 0; i < fileCount; ++i) { - QFile f(testDir.filePath(QString("test%1.txt").arg(i))); + const QByteArray iB = QByteArray::number(i); + QFile f(testDir.filePath(QLatin1String("test") + QString::fromLatin1(iB) + QLatin1String(".txt"))); QVERIFY(f.open(QIODevice::WriteOnly)); - f.write(QByteArray("i am ") + QByteArray::number(i)); + f.write(QByteArray("i am ") + iB); f.close(); } diff --git a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp index 5ece9190a5..304cf7b551 100644 --- a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp +++ b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp @@ -69,8 +69,9 @@ void tst_QNoDebug::noDebugOutput() const void tst_QNoDebug::streaming() const { QDateTime dt(QDate(1,2,3),QTime(4,5,6)); - const QString debugString = dt.toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz t")); - QTest::ignoreMessage(QtWarningMsg, qPrintable(QString::fromLatin1("QDateTime(%1 Qt::TimeSpec(LocalTime))").arg(debugString))); + const QByteArray debugString = dt.toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz t")).toLatin1(); + const QByteArray message = "QDateTime(" + debugString + " Qt::TimeSpec(LocalTime))"; + QTest::ignoreMessage(QtWarningMsg, message.constData()); qWarning() << dt; } diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index a520010b47..30812700c5 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -2621,7 +2621,7 @@ QString escapeWeirdChars(const QString &s) QChar c = s.at(i); if (c.unicode() < ' ' || c.unicode() > '~' || (escapeNextDigit && c.unicode() >= '0' && c.unicode() <= 'f')) { - result += QString("\\x%1").arg(c.unicode(), 0, 16); + result += QLatin1String("\\x") + QString::number(c.unicode(), 16); escapeNextDigit = true; } else { result += c; diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index b64753e798..97dfac3062 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -2872,7 +2872,8 @@ void tst_QUrl::fromUserInput_data() int c = 0; while (it.hasNext()) { it.next(); - QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.filePath() << QUrl::fromLocalFile(it.filePath()); + QTest::newRow(("file-" + QByteArray::number(c++)).constData()) + << it.filePath() << QUrl::fromLocalFile(it.filePath()); } // basic latin1 @@ -2960,7 +2961,8 @@ void tst_QUrl::fromUserInputWithCwd_data() while (it.hasNext()) { it.next(); QUrl url = QUrl::fromLocalFile(it.filePath()); - QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.fileName() << QDir::currentPath() << url << url; + QTest::newRow(("file-" + QByteArray::number(c++)).constData()) + << it.fileName() << QDir::currentPath() << url << url; } QDir parent = QDir::current(); QVERIFY(parent.cdUp()); diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index 450a1f84c6..2570beb6c2 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -157,9 +157,10 @@ QtTestModel::QtTestModel(int rows, int columns, QObject *parent) { table.resize(rows); for (int r = 0; r < rows; ++r) { + const QString prefix = QString::number(r) + QLatin1Char('/'); table[r].resize(columns); for (int c = 0; c < columns; ++c) - table[r][c] = QString("%1/%2").arg(r).arg(c); + table[r][c] = prefix + QString::number(c); } } diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index 208214fbc5..fbab95c975 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -146,7 +146,7 @@ void tst_QIdentityProxyModel::insertRows() { QStandardItem *parentItem = m_model->invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -186,7 +186,7 @@ void tst_QIdentityProxyModel::removeRows() { QStandardItem *parentItem = m_model->invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp index 0c8e5690d0..e47b2e2e69 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp @@ -311,7 +311,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) Q_FUNC_INFO, qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test"))); for (int i = 0; i < 26; ++i) { - QString subdir = QString("test/foo_%1").arg(i); + QString subdir = QLatin1String("test/foo_") + QString::number(i); if (!QDir::current().mkdir(subdir)) qFatal("%s: cannot create directory %s", Q_FUNC_INFO, @@ -350,7 +350,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) int items = 50; #endif while (items--) - listWidget->addItem(QString("item %1").arg(items)); + listWidget->addItem(QLatin1String("item ") + QString::number(items)); return QModelIndex(); } @@ -365,9 +365,10 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) treeWidget->setColumnCount(1); QTreeWidgetItem *parent; while (topItems--){ - parent = new QTreeWidgetItem(treeWidget, QStringList(QString("top %1").arg(topItems))); + const QString tS = QString::number(topItems); + parent = new QTreeWidgetItem(treeWidget, QStringList(QLatin1String("top ") + tS)); for (int i = 0; i < 20; ++i) - new QTreeWidgetItem(parent, QStringList(QString("child %1").arg(topItems))); + new QTreeWidgetItem(parent, QStringList(QLatin1String("child ") + tS)); } return QModelIndex(); } @@ -387,7 +388,7 @@ void ModelsToTest::cleanupTestArea(QAbstractItemModel *model) if (QDir(QDir::currentPath()+"/test").exists()) { for (int i = 0; i < 26; ++i) { - QString subdir(QString("test/foo_%1").arg(i)); + QString subdir(QLatin1String("test/foo_") + QString::number(i)); if (!QDir::current().rmdir(subdir)) qFatal("%s: cannot remove directory %s", Q_FUNC_INFO, diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 629bbad5aa..7d5c30dfb5 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -1974,8 +1974,9 @@ void tst_QItemSelectionModel::rowIntersectsSelection2() { QStandardItemModel m; for (int i=0; i<8; ++i) { + const QString text = QLatin1String("Item number ") + QString::number(i); for (int j=0; j<8; ++j) { - QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i)); + QStandardItem *item = new QStandardItem(text); if ((i % 2 == 0 && j == 0) || (j % 2 == 0 && i == 0) || j == 5 || i == 5 ) { @@ -2021,7 +2022,7 @@ void tst_QItemSelectionModel::rowIntersectsSelection3() QStandardItemModel model; QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -2046,7 +2047,7 @@ void tst_QItemSelectionModel::unselectable() QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 10; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); } QItemSelectionModel selectionModel(&model); @@ -2093,7 +2094,8 @@ public: QVariant data(const QModelIndex &idx, int role) const { if (role == Qt::DisplayRole || role == Qt::EditRole) - return QString("[%1,%2]").arg(idx.row()).arg(idx.column()); + return QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',') + + QString::number(idx.column()) + QLatin1Char(']'); return QVariant(); } @@ -2202,7 +2204,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -2225,13 +2227,14 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() parentItem = model.invisibleRootItem(); for (int i = 0; i < 2; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); } for (int i = 0; i < 2; ++i) { parentItem = model.invisibleRootItem()->child(i, 0); + const QString prefix = QLatin1String("item ") + QString::number(i) + QLatin1Char('.'); for (int j = 0; j < 2; ++j) { - QStandardItem *item = new QStandardItem(QString("item %0.%1").arg(i).arg(j)); + QStandardItem *item = new QStandardItem(prefix + QString::number(j)); parentItem->appendRow(item); } } @@ -2304,13 +2307,12 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected2() // Populate the tree view. for (unsigned int i = 0; i < cNumCols; i++) - model.setHeaderData( i, Qt::Horizontal, QString::fromLatin1("Column %1").arg(i)); + model.setHeaderData( i, Qt::Horizontal, QLatin1String("Column ") + QString::number(i)); for (unsigned int r = 0; r < cNumRows; r++) { - for (unsigned int c = 0; c < cNumCols; c++) { - model.setData(model.index(r, c, QModelIndex()), - QString::fromLatin1("r:%1/c:%2").arg(r, c)); - } + const QString prefix = QLatin1String("r:") + QString::number(r) + QLatin1String("/c:"); + for (unsigned int c = 0; c < cNumCols; c++) + model.setData(model.index(r, c, QModelIndex()), prefix + QString::number(c)); } QCOMPARE(model.rowCount(), int(cNumRows)); @@ -2412,15 +2414,16 @@ static QStandardItemModel* getModel(QObject *parent) for (int i = 0; i < 4; ++i) { QStandardItem *parentItem = model->invisibleRootItem(); QList list; + const QString prefix = QLatin1String("item ") + QString::number(i) + QLatin1String(", "); for (int j = 0; j < 4; ++j) { - list.append(new QStandardItem(QString("item %1, %2").arg(i).arg(j))); + list.append(new QStandardItem(prefix + QString::number(j))); } parentItem->appendRow(list); parentItem = list.first(); for (int j = 0; j < 4; ++j) { QList list; for (int k = 0; k < 4; ++k) { - list.append(new QStandardItem(QString("item %1, %2").arg(i).arg(j))); + list.append(new QStandardItem(prefix + QString::number(j))); } parentItem->appendRow(list); } diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 12b3d983c0..7d93818797 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -341,7 +341,7 @@ void tst_QSortFilterProxyModel::sort_data() QStringList list; for (int i = 10000; i < 20000; ++i) - list.append(QString("Number: %1").arg(i)); + list.append(QStringLiteral("Number: ") + QString::number(i)); QTest::newRow("large set ascending") << static_cast(Qt::AscendingOrder) << int(Qt::CaseSensitive) << list << list; } @@ -2545,12 +2545,11 @@ void tst_QSortFilterProxyModel::sortStable() { QStandardItemModel* model = new QStandardItemModel(5, 2); for (int r = 0; r < 5; r++) { + const QString prefix = QLatin1String("Row:") + QString::number(r) + QLatin1String(", Column:"); for (int c = 0; c < 2; c++) { - QStandardItem* item = new QStandardItem( - QString("Row:%0, Column:%1").arg(r).arg(c) ); + QStandardItem* item = new QStandardItem(prefix + QString::number(c)); for (int i = 0; i < 3; i++) { - QStandardItem* child = new QStandardItem( - QString("Item %0").arg(i) ); + QStandardItem* child = new QStandardItem(QLatin1String("Item ") + QString::number(i)); item->appendRow( child ); } model->setItem(r, c, item); @@ -2806,7 +2805,8 @@ public: qWarning("Invalid modelIndex [%d,%d,%p]", idx.row(), idx.column(), idx.internalPointer()); } - return QString("[%1,%2]").arg(idx.row()).arg(idx.column()); + return QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',') + + QString::number(idx.column()) + QLatin1Char(']'); } return QVariant(); } @@ -2971,7 +2971,7 @@ void tst_QSortFilterProxyModel::doubleProxySelectionSetSourceModel() QStandardItemModel *model1 = new QStandardItemModel; QStandardItem *parentItem = model1->invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("model1 item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("model1 item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -2979,7 +2979,7 @@ void tst_QSortFilterProxyModel::doubleProxySelectionSetSourceModel() QStandardItemModel *model2 = new QStandardItemModel; QStandardItem *parentItem2 = model2->invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("model2 item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("model2 item ") + QString::number(i)); parentItem2->appendRow(item); parentItem2 = item; } @@ -3554,11 +3554,11 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 4; ++i) { { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); } { - QStandardItem *item = new QStandardItem(QString("item 1%0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item 1") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -3855,9 +3855,10 @@ void tst_QSortFilterProxyModel::hierarchyFilterInvalidation() { QStandardItemModel model; for (int i = 0; i < 10; ++i) { - QStandardItem *child = new QStandardItem(QString("Row %1").arg(i)); + const QString rowText = QLatin1String("Row ") + QString::number(i); + QStandardItem *child = new QStandardItem(rowText); for (int j = 0; j < 1; ++j) { - child->appendRow(new QStandardItem(QString("Row %1/%2").arg(i).arg(j))); + child->appendRow(new QStandardItem(rowText + QLatin1Char('/') + QString::number(j))); } model.appendRow(child); } @@ -3916,7 +3917,7 @@ void tst_QSortFilterProxyModel::simpleFilterInvalidation() { QStandardItemModel model; for (int i = 0; i < 2; ++i) { - QStandardItem *child = new QStandardItem(QString("Row %1").arg(i)); + QStandardItem *child = new QStandardItem(QLatin1String("Row ") + QString::number(i)); child->appendRow(new QStandardItem("child")); model.appendRow(child); } diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index d4e83933a9..1fde3d4cff 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -193,8 +193,11 @@ protected: Bar space[1]; space[0].~Bar(); + const QByteArray postFix = '_' + + QByteArray::number(reinterpret_cast(QThread::currentThreadId())); + for (int i = 0; i < 1000; ++i) { - const QByteArray name = QString("Bar%1_%2").arg(i).arg((size_t)QThread::currentThreadId()).toLatin1(); + const QByteArray name = "Bar" + QByteArray::number(i) + postFix; const char *nm = name.constData(); int tp = qRegisterMetaType(nm); #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp index dbac689ebb..2cba521b61 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp @@ -481,7 +481,7 @@ void tst_QSharedMemory::useTooMuchMemory() bool success = true; int count = 0; while (success) { - QString key = QString("maxmemorytest_%1").arg(count++); + QString key = QLatin1String("maxmemorytest_") + QString::number(count++); QSharedMemory *sm = new QSharedMemory(rememberKey(key)); QVERIFY(sm); jail.append(sm); diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 72bd38d116..9640c52623 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -95,7 +95,8 @@ static QString sys_qualifiedLibraryName(const QString &fileName) { - QString libname = QFINDTESTDATA(QString("bin/%1%2%3").arg(PREFIX).arg(fileName).arg(SUFFIX)); + QString name = QLatin1String("bin/") + QLatin1String(PREFIX) + fileName + QLatin1String(SUFFIX); + const QString libname = QFINDTESTDATA(name); QFileInfo fi(libname); if (fi.exists()) return fi.canonicalFilePath(); @@ -386,7 +387,8 @@ void tst_QPluginLoader::loadMachO() void tst_QPluginLoader::loadGarbage() { for (int i=0; i<5; i++) { - QPluginLoader lib(QFINDTESTDATA(QString("elftest/garbage%1.so").arg(i+1))); + const QString name = QLatin1String("elftest/garbage") + QString::number(i + 1) + QLatin1String(".so"); + QPluginLoader lib(QFINDTESTDATA(name)); QCOMPARE(lib.load(), false); QVERIFY(lib.errorString() != QString("Unknown error")); } diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 7a94d922c9..4a8190da6d 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -212,12 +212,12 @@ QByteArray verifyZeroTermination(const QByteArray &ba) const_cast(baData)[baSize] = 'x'; if ('x' != ba.constData()[baSize]) { - return QString::fromLatin1("*** Failed to replace null-terminator in " - "result ('%1') ***").arg(QString::fromLatin1(ba)).toLatin1(); + return "*** Failed to replace null-terminator in " + "result ('" + ba + "') ***"; } if (ba != baCopy) { - return QString::fromLatin1( "*** Result ('%1') differs from its copy " - "after null-terminator was replaced ***").arg(QString::fromLatin1(ba)).toLatin1(); + return "*** Result ('" + ba + "') differs from its copy " + "after null-terminator was replaced ***"; } const_cast(baData)[baSize] = '\0'; // Restore sanity diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index 3a24c82f9e..c2bef14767 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -239,8 +239,8 @@ void tst_QChar::isDigit_data() for (ushort ucs = 0; ucs < 256; ++ucs) { bool isDigit = (ucs <= '9' && ucs >= '0'); - QString tag = QString::fromLatin1("0x%0").arg(QString::number(ucs, 16)); - QTest::newRow(tag.toLatin1()) << ucs << isDigit; + const QByteArray tag = "0x" + QByteArray::number(ucs, 16); + QTest::newRow(tag.constData()) << ucs << isDigit; } } @@ -266,8 +266,8 @@ void tst_QChar::isLetter_data() QTest::addColumn("expected"); for (ushort ucs = 0; ucs < 256; ++ucs) { - QString tag = QString::fromLatin1("0x%0").arg(QString::number(ucs, 16)); - QTest::newRow(tag.toLatin1()) << ucs << isExpectedLetter(ucs); + const QByteArray tag = "0x" + QByteArray::number(ucs, 16); + QTest::newRow(tag.constData()) << ucs << isExpectedLetter(ucs); } } @@ -288,8 +288,8 @@ void tst_QChar::isLetterOrNumber_data() || (ucs >= '0' && ucs <= '9') || ucs == 0xB2 || ucs == 0xB3 || ucs == 0xB9 || (ucs >= 0xBC && ucs <= 0xBE); - QString tag = QString::fromLatin1("0x%0").arg(QString::number(ucs, 16)); - QTest::newRow(tag.toLatin1()) << ucs << isLetterOrNumber; + const QByteArray tag = "0x" + QByteArray::number(ucs, 16); + QTest::newRow(tag.constData()) << ucs << isLetterOrNumber; } } @@ -403,8 +403,8 @@ void tst_QChar::isSpace_data() for (ushort ucs = 0; ucs < 256; ++ucs) { bool isSpace = (ucs <= 0x0D && ucs >= 0x09) || ucs == 0x20 || ucs == 0xA0 || ucs == 0x85; - QString tag = QString::fromLatin1("0x%0").arg(QString::number(ucs, 16)); - QTest::newRow(tag.toLatin1()) << ucs << isSpace; + const QByteArray tag = "0x" + QByteArray::number(ucs, 16); + QTest::newRow(tag.constData()) << ucs << isSpace; } } @@ -793,8 +793,10 @@ void tst_QChar::normalization_data() } } - QString nm = QString("line #%1 (part %2").arg(linenum).arg(part); - QTest::newRow(nm.toLatin1()) << columns << part; + + const QByteArray nm = "line #" + QByteArray::number(linenum) + " (part " + + QByteArray::number(part); + QTest::newRow(nm.constData()) << columns << part; } } diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 571e8deb00..da5039ce3b 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -1691,13 +1691,15 @@ void tst_QDateTime::operator_insert_extract_data() const int thisVersion = tmpDataStream.version(); for (int version = QDataStream::Qt_1_0; version <= thisVersion; ++version) { const QDataStream::Version dataStreamVersion = static_cast(version); - QTest::newRow(QString::fromLatin1("v%1 WA => HAWAII %2").arg(dataStreamVersion).arg(positiveYear.toString()).toLocal8Bit().constData()) + const QByteArray vN = QByteArray::number(dataStreamVersion); + const QByteArray pY = positiveYear.toString().toLatin1(); + QTest::newRow(('v' + vN + " WA => HAWAII " + pY).constData()) << positiveYear << westernAustralia << hawaii << dataStreamVersion; - QTest::newRow(QString::fromLatin1("v%1 WA => WA %2").arg(dataStreamVersion).arg(positiveYear.toString()).toLocal8Bit().constData()) + QTest::newRow(('v' + vN + " WA => WA " + pY).constData()) << positiveYear << westernAustralia << westernAustralia << dataStreamVersion; - QTest::newRow(QString::fromLatin1("v%1 HAWAII => WA %2").arg(dataStreamVersion).arg(negativeYear.toString()).toLocal8Bit().constData()) + QTest::newRow(('v' + vN + " HAWAII => WA " + negativeYear.toString().toLatin1()).constData()) << negativeYear << hawaii << westernAustralia << dataStreamVersion; - QTest::newRow(QString::fromLatin1("v%1 HAWAII => HAWAII %2").arg(dataStreamVersion).arg(positiveYear.toString()).toLocal8Bit().constData()) + QTest::newRow(('v' + vN + " HAWAII => HAWAII " + pY).constData()) << positiveYear << hawaii << hawaii << dataStreamVersion; } } diff --git a/tests/auto/corelib/tools/qline/tst_qline.cpp b/tests/auto/corelib/tools/qline/tst_qline.cpp index 20373bfb15..a215464d8a 100644 --- a/tests/auto/corelib/tools/qline/tst_qline.cpp +++ b/tests/auto/corelib/tools/qline/tst_qline.cpp @@ -179,7 +179,7 @@ void tst_QLine::testIntersection_data() a = a.translated(1, 1); b = b.translated(1, 1); - QTest::newRow(qPrintable(QString::fromLatin1("rotation-%0").arg(i))) + QTest::newRow(("rotation-" + QByteArray::number(i)).constData()) << (double)a.x1() << (double)a.y1() << (double)a.x2() << (double)a.y2() << (double)b.x1() << (double)b.y1() << (double)b.x2() << (double)b.y2() << int(QLineF::BoundedIntersection) @@ -332,7 +332,7 @@ void tst_QLine::testAngle_data() << 135.0; for (int i=0; i<180; ++i) { - QTest::newRow(QString("angle:%1").arg(i).toLatin1()) + QTest::newRow(("angle:" + QByteArray::number(i)).constData()) << 0.0 << 0.0 << double(cos(i*M_2PI/360)) << double(sin(i*M_2PI/360)) << 0.0 << 0.0 << 1.0 << 0.0 << double(i); @@ -460,7 +460,7 @@ void tst_QLine::testAngleTo_data() for (int i = 0; i < 360; ++i) { const QLineF l = QLineF::fromPolar(1, i); - QTest::newRow(QString("angle:%1").arg(i).toLatin1()) + QTest::newRow(("angle:" + QByteArray::number(i)).constData()) << qreal(0.0) << qreal(0.0) << qreal(1.0) << qreal(0.0) << qreal(0.0) << qreal(0.0) << l.p2().x() << l.p2().y() << qreal(i); diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 6c4fc5e62b..33c8eb303a 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1697,9 +1697,11 @@ void tst_QLocale::testNames_data() for (int i = 0; i < locale_data_count; ++i) { const QLocaleData &item = locale_data[i]; - const QString testName = QString::fromLatin1("data_%1 (%2/%3)").arg(i) - .arg(QLocale::languageToString((QLocale::Language)item.m_language_id)) - .arg(QLocale::countryToString((QLocale::Country)item.m_country_id)); + + const QString testName = QLatin1String("data_") + QString::number(i) + QLatin1String(" (") + + QLocale::languageToString((QLocale::Language)item.m_language_id) + + QLatin1Char('/') + QLocale::countryToString((QLocale::Country)item.m_country_id) + + QLatin1Char(')'); QTest::newRow(testName.toLatin1().constData()) << (int)item.m_language_id << (int)item.m_country_id; } } diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 7cd7d7980f..daaabbb523 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1062,7 +1062,7 @@ void tst_QMap::equal_range() QCOMPARE(cresult.second, cmap.cend()); for (int i = -10; i < 10; i += 2) - map.insert(i, QString("%1").arg(i)); + map.insert(i, QString::number(i)); result = map.equal_range(0); QCOMPARE(result.first, map.find(0)); diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index 23259e520f..1d8b719d16 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -1370,12 +1370,14 @@ void tst_QRegExp::escapeSequences() { QString perlSyntaxSpecialChars("0123456789afnrtvbBdDwWsSx\\|[]{}()^$?+*"); QString w3cXmlSchema11SyntaxSpecialChars("cCiIpP"); // as well as the perl ones + QString pattern = QLatin1String("\\?"); for (int i = ' '; i <= 127; ++i) { QLatin1Char c(i); if (perlSyntaxSpecialChars.indexOf(c) == -1) { - QRegExp rx(QString("\\%1").arg(c), Qt::CaseSensitive, QRegExp::RegExp); + pattern[1] = c; + QRegExp rx(pattern, Qt::CaseSensitive, QRegExp::RegExp); // we'll never have c == 'a' since it's a special character - QString s = QString("aaa%1aaa").arg(c); + const QString s = QLatin1String("aaa") + c + QLatin1String("aaa"); QCOMPARE(rx.indexIn(s), 3); rx.setPatternSyntax(QRegExp::RegExp2); diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 8ddd4979b6..6be4e69eb7 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -656,7 +656,7 @@ void tst_QRegularExpression::normalMatch_data() m.captured << "c123def" << "c12" << "3" << "def"; offset = 2; for (int i = 0; i <= offset; ++i) { - QTest::newRow(QStringLiteral("match06-offset%1").arg(i).toUtf8().constData()) + QTest::newRow(("match06-offset" + QByteArray::number(i)).constData()) << QRegularExpression("(\\w*)(\\d+)(\\w*)") << QStringLiteral("abc123def").mid(offset - i) << i @@ -669,7 +669,7 @@ void tst_QRegularExpression::normalMatch_data() m.captured << QString(""); offset = 9; for (int i = 0; i <= offset; ++i) { - QTest::newRow(QStringLiteral("match07-offset%1").arg(i).toUtf8().constData()) + QTest::newRow(("match07-offset" + QByteArray::number(i)).constData()) << QRegularExpression("\\w*") << QStringLiteral("abc123def").mid(offset - i) << i @@ -747,7 +747,7 @@ void tst_QRegularExpression::normalMatch_data() m.isValid = true; offset = 1; for (int i = 0; i <= offset; ++i) { - QTest::newRow(QStringLiteral("nomatch02-offset%1").arg(i).toUtf8().constData()) + QTest::newRow(("nomatch02-offset" + QByteArray::number(i)).constData()) << QRegularExpression("(\\w+) (\\w+)") << QStringLiteral("a string").mid(offset - i) << i @@ -759,7 +759,7 @@ void tst_QRegularExpression::normalMatch_data() m.isValid = true; offset = 9; for (int i = 0; i <= offset; ++i) { - QTest::newRow(QStringLiteral("nomatch03-offset%1").arg(i).toUtf8().constData()) + QTest::newRow(("nomatch03-offset" + QByteArray::number(i)).constData()) << QRegularExpression("\\w+") << QStringLiteral("abc123def").mid(offset - i) << i @@ -930,7 +930,7 @@ void tst_QRegularExpression::partialMatch_data() m.captured << "def"; offset = 1; for (int i = 0; i <= offset; ++i) { - QTest::newRow(QStringLiteral("softmatch08-offset%1").arg(i).toUtf8().constData()) + QTest::newRow(("softmatch08-offset" + QByteArray::number(i)).constData()) << QRegularExpression("abc\\w+X|defY") << QStringLiteral("abcdef").mid(offset - i) << i @@ -1016,7 +1016,7 @@ void tst_QRegularExpression::partialMatch_data() m.captured << "def"; offset = 1; for (int i = 0; i <= offset; ++i) { - QTest::newRow(QStringLiteral("hardmatch08-offset%1").arg(i).toUtf8().constData()) + QTest::newRow(("hardmatch08-offset" + QByteArray::number(i)).constData()) << QRegularExpression("abc\\w+X|defY") << QStringLiteral("abcdef").mid(offset - i) << i diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp index 2695e6238c..b77fe23bd6 100644 --- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp +++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp @@ -150,7 +150,7 @@ void tst_QRingBuffer::readPointerAtPositionWriteRead() inData.putChar(0x23); inData.write("Qt rocks!"); for (int i = 0; i < 5000; i++) - inData.write(QString("Number %1").arg(i).toUtf8()); + inData.write("Number " + QByteArray::number(i)); inData.reset(); QVERIFY(inData.size() > 0); diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 124829a11c..6b84fa367b 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -63,7 +63,7 @@ #include #define CREATE_REF(string) \ - const QString padded = QString::fromLatin1(" %1 ").arg(string); \ + const QString padded = QLatin1Char(' ') + string + QLatin1Char(' '); \ QStringRef ref = padded.midRef(1, padded.size() - 2); namespace { diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index 15bcb1ee2b..b3599b6a5c 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -97,7 +97,7 @@ static QStringRef emptyRef() } #define CREATE_REF(string) \ - const QString padded = QString::fromLatin1(" %1 ").arg(string); \ + const QString padded = QLatin1Char(' ') + string + QLatin1Char(' '); \ QStringRef ref = padded.midRef(1, padded.size() - 2); typedef QList IntList; @@ -317,8 +317,8 @@ void tst_QStringRef::indexOf() QFETCH(bool, bcs); QFETCH(int, resultpos); - const QString haystackPadded = QString::fromLatin1(" %1 ").arg(haystack); - const QString needlePadded = QString::fromLatin1(" %1 ").arg(needle); + const QString haystackPadded = QLatin1Char(' ') + haystack + QLatin1Char(' '); + const QString needlePadded = QLatin1Char(' ') + needle + QLatin1Char(' '); const QStringRef haystackRef(&haystackPadded, 1, haystack.size()); const QStringRef needleRef(&needlePadded, 1, needle.size()); @@ -407,8 +407,8 @@ void tst_QStringRef::indexOf2() QFETCH(QString, needle); QFETCH(int, resultpos); - const QString haystackPadded = QString::fromLatin1(" %1 ").arg(haystack); - const QString needlePadded = QString::fromLatin1(" %1 ").arg(needle); + const QString haystackPadded = QLatin1Char(' ') + haystack + QLatin1Char(' '); + const QString needlePadded = QLatin1Char(' ') + needle + QLatin1Char(' '); const QStringRef haystackRef(&haystackPadded, 1, haystack.size()); const QStringRef needleRef(&needlePadded, 1, needle.size()); @@ -490,8 +490,8 @@ void tst_QStringRef::lastIndexOf() QFETCH(int, expected); QFETCH(bool, caseSensitive); - const QString haystackPadded = QString::fromLatin1(" %1 ").arg(haystack); - const QString needlePadded = QString::fromLatin1(" %1 ").arg(needle); + const QString haystackPadded = QLatin1Char(' ') + haystack + QLatin1Char(' '); + const QString needlePadded = QLatin1Char(' ') + needle + QLatin1Char(' '); const QStringRef haystackRef(&haystackPadded, 1, haystack.size()); const QStringRef needleRef(&needlePadded, 1, needle.size()); diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 753d61f02c..927c07f9e6 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -166,8 +166,8 @@ static void generateDataFromFile(const QString &fname) } } - QString nm = QString("line #%1: %2").arg(linenum).arg(comments); - QTest::newRow(nm.toLatin1()) << testString << expectedBreakPositions; + const QByteArray nm = "line #" + QByteArray::number(linenum) + ": " + comments.toLatin1(); + QTest::newRow(nm.constData()) << testString << expectedBreakPositions; } } #endif diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 87822bca6f..bdfb567331 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -2391,6 +2391,7 @@ void tst_QVector::reallocAfterCopy_data() int result1, result2, result3, result4; int fill_size; for (int i = 70; i <= 100; i += 10) { + const QByteArray prefix = "reallocAfterCopy:" + QByteArray::number(i) + ','; fill_size = i - 20; for (int j = 0; j <= 3; j++) { if (j == 0) { // append @@ -2414,7 +2415,8 @@ void tst_QVector::reallocAfterCopy_data() result3 = i - 10; result4 = i - 20; } - QTest::newRow(qPrintable(QString("reallocAfterCopy:%1,%2").arg(i).arg(j))) << i << fill_size << j << result1 << result2 << result3 << result4; + QTest::newRow((prefix + QByteArray::number(j)).constData()) + << i << fill_size << j << result1 << result2 << result3 << result4; } } } diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp index 94b785ae1d..c87595c3c9 100644 --- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp @@ -157,7 +157,7 @@ static QByteArray makeCanonical(const QString &filename, text.indexOf(QLatin1Char(13), p), text.indexOf(QLatin1Char(9), p))) >= 0) { writer.writeCharacters(text.mid(p, i - p)); - writer.writeEntityReference(QString("#%1").arg(text.at(i).unicode())); + writer.writeEntityReference(QLatin1Char('#') + QString::number(text.at(i).unicode())); p = i + 1; } writer.writeCharacters(text.mid(p)); @@ -357,7 +357,7 @@ public: QFile inputFile(inputFilePath); if(!inputFile.open(QIODevice::ReadOnly)) { - failures.append(qMakePair(id, QString::fromLatin1("Failed to open input file %1").arg(inputFilePath))); + failures.append(qMakePair(id, QLatin1String("Failed to open input file ") + inputFilePath)); return true; } @@ -365,8 +365,8 @@ public: { if(isWellformed(&inputFile, ParseSinglePass)) { - failures.append(qMakePair(id, QString::fromLatin1("Failed to flag %1 as not well-formed.") - .arg(inputFilePath))); + failures.append(qMakePair(id, QLatin1String("Failed to flag ") + inputFilePath + + QLatin1String(" as not well-formed."))); /* Exit, the incremental test will fail as well, no need to flood the output. */ return true; @@ -376,8 +376,8 @@ public: if(isWellformed(&inputFile, ParseIncrementally)) { - failures.append(qMakePair(id, QString::fromLatin1("Failed to flag %1 as not well-formed with incremental parsing.") - .arg(inputFilePath))); + failures.append(qMakePair(id, QLatin1String("Failed to flag ") + inputFilePath + + QLatin1String(" as not well-formed with incremental parsing."))); } else successes.append(id); @@ -402,7 +402,7 @@ public: if(!expectedFile.open(QIODevice::ReadOnly)) { - failures.append(qMakePair(id, QString::fromLatin1("Failed to open baseline %1").arg(expectedFilePath))); + failures.append(qMakePair(id, QLatin1String("Failed to open baseline ") + expectedFilePath)); return true; } @@ -665,8 +665,10 @@ void tst_QXmlStream::reportSuccess_data() const const int len = m_handler.successes.count(); - for(int i = 0; i < len; ++i) - QTest::newRow(qPrintable(QString("%1. %2").arg(i).arg(m_handler.successes.at(i)))) << false; + for (int i = 0; i < len; ++i) { + const QByteArray testName = QByteArray::number(i) + ". " + m_handler.successes.at(i).toLatin1(); + QTest::newRow(testName.constData()) << false; + } if(len == 0) QTest::newRow("No test cases succeeded.") << true; @@ -978,7 +980,8 @@ void tst_QXmlStream::writeAttributesWithSpace() const writer.writeEmptyElement("A"); writer.writeAttribute("attribute", QStringLiteral("value") + QChar(QChar::Nbsp)); writer.writeEndDocument(); - QString s = QString("\n").arg(QChar(QChar::Nbsp)); + QString s = QLatin1String("\n"); QCOMPARE(buffer.buffer().data(), s.toUtf8().data()); }