tests/auto/corelib: Remove some placeholder formatting.
Use QByteArray/QString addition instead in loops and for test row names. Change-Id: Ieffb429efdc14aa5932b3fcdef5a18e13a62d35f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
This commit is contained in:
parent
acdd4850a4
commit
456f721917
@ -340,7 +340,7 @@ void tst_QDataStream::stream_data(int noOfElements)
|
||||
|
||||
QString tag = device + QLatin1Char('_') + byte_order;
|
||||
for (int e=0; e<noOfElements; e++) {
|
||||
QTest::newRow(qPrintable(tag + QString("_%1").arg(e))) << device << QString(byte_order);
|
||||
QTest::newRow(qPrintable(tag + QLatin1Char('_') + QString::number(e))) << device << byte_order;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2072,7 +2072,7 @@ void tst_QDataStream::setVersion_data()
|
||||
QDataStream latest;
|
||||
|
||||
for (int vers = 1; vers <= latest.version(); ++vers)
|
||||
QTest::newRow(qPrintable(QString("v_%1").arg(vers))) << vers;
|
||||
QTest::newRow(("v_" + QByteArray::number(vers)).constData()) << vers;
|
||||
}
|
||||
|
||||
void tst_QDataStream::setVersion()
|
||||
|
@ -556,7 +556,7 @@ void tst_QDir::exists_data()
|
||||
char drive = 'Z';
|
||||
QString driv;
|
||||
do {
|
||||
driv = QString::fromLatin1("%1:/").arg(drive);
|
||||
driv = drive + QLatin1String(":/");
|
||||
if (!driveLetters.contains(driv)) break;
|
||||
--drive;
|
||||
} while (drive >= 'A');
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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<QStandardItem*> 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<QStandardItem*> 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);
|
||||
}
|
||||
|
@ -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<int>(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);
|
||||
}
|
||||
|
@ -193,8 +193,11 @@ protected:
|
||||
Bar space[1];
|
||||
space[0].~Bar();
|
||||
|
||||
const QByteArray postFix = '_'
|
||||
+ QByteArray::number(reinterpret_cast<quintptr>(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<Bar>(nm);
|
||||
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||
|
@ -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);
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -212,12 +212,12 @@ QByteArray verifyZeroTermination(const QByteArray &ba)
|
||||
|
||||
const_cast<char *>(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<char *>(baData)[baSize] = '\0'; // Restore sanity
|
||||
|
||||
|
@ -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<bool>("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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<QDataStream::Version>(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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#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 {
|
||||
|
@ -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<int> 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());
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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("<?xml version=\"1.0\" encoding=\"UTF-8\"?><A attribute=\"value%1\"/>\n").arg(QChar(QChar::Nbsp));
|
||||
QString s = QLatin1String("<?xml version=\"1.0\" encoding=\"UTF-8\"?><A attribute=\"value")
|
||||
+ QChar(QChar::Nbsp) + QLatin1String("\"/>\n");
|
||||
QCOMPARE(buffer.buffer().data(), s.toUtf8().data());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user