Tests: Fix single-character string literals.

Use character literals where applicable.

Change-Id: I1a026c320079ee5ca6f70be835d5a541deee2dd1
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This commit is contained in:
Friedemann Kleint 2015-10-13 09:46:56 +02:00
parent e86f889de7
commit a2a00eb044
82 changed files with 264 additions and 260 deletions

View File

@ -265,7 +265,7 @@ void tst_QTextCodec::fromUnicode()
array is correct (no off by one, no trailing '\0').
*/
QByteArray result = codec->fromUnicode(QString("abc"));
if (result.startsWith("a")) {
if (result.startsWith('a')) {
QCOMPARE(result.size(), 3);
QCOMPARE(result, QByteArray("abc"));
} else {
@ -573,7 +573,7 @@ void tst_QTextCodec::utf8Codec_data()
str = "Prohl";
str += QChar::ReplacementCharacter;
str += QChar::ReplacementCharacter;
str += "e";
str += QLatin1Char('e');
str += QChar::ReplacementCharacter;
str += " plugin";
str += QChar::ReplacementCharacter;

View File

@ -821,7 +821,7 @@ void tst_qmessagehandler::qMessagePattern()
// test QT_MESSAGE_PATTERN
//
QStringList environment = m_baseEnvironment;
environment.prepend("QT_MESSAGE_PATTERN=\"" + pattern + "\"");
environment.prepend("QT_MESSAGE_PATTERN=\"" + pattern + QLatin1Char('"'));
process.setEnvironment(environment);
process.start(appExe);

View File

@ -301,7 +301,7 @@ void tst_QDataStream::cleanupTestCase()
static int dataIndex(const QString &tag)
{
int pos = tag.lastIndexOf("_");
int pos = tag.lastIndexOf(QLatin1Char('_'));
if (pos >= 0) {
int ret = 0;
QString count = tag.mid(pos + 1);
@ -338,7 +338,7 @@ void tst_QDataStream::stream_data(int noOfElements)
for (int b=0; b<2; b++) {
QString byte_order = b == 0 ? "BigEndian" : "LittleEndian";
QString tag = device + "_" + byte_order;
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);
}

View File

@ -1063,7 +1063,7 @@ void tst_QDir::cd_data()
QTest::addColumn<bool>("successExpected");
QTest::addColumn<QString>("newDir");
int index = m_dataPath.lastIndexOf("/");
int index = m_dataPath.lastIndexOf(QLatin1Char('/'));
QTest::newRow("cdUp") << m_dataPath << ".." << true << m_dataPath.left(index==0?1:index);
QTest::newRow("cdUp non existent (relative dir)") << "anonexistingDir" << ".."
<< true << m_dataPath;
@ -1107,11 +1107,11 @@ void tst_QDir::setNameFilters_data()
QTest::newRow("spaces2") << m_dataPath + "/testdir/spaces" << QStringList("*.bar")
<< QStringList("foo.bar");
QTest::newRow("spaces3") << m_dataPath + "/testdir/spaces" << QStringList("foo.*")
<< QString("foo. bar,foo.bar").split(",");
QTest::newRow("files1") << m_dataPath + "/testdir/dir" << QString("*r.cpp *.pro").split(" ")
<< QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(",");
<< QString("foo. bar,foo.bar").split(QLatin1Char(','));
QTest::newRow("files1") << m_dataPath + "/testdir/dir" << QString("*r.cpp *.pro").split(QLatin1Char(' '))
<< QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(QLatin1Char(','));
QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data")
<< QString("file1.data,file2.data,file3.data").split(',');
<< QString("file1.data,file2.data,file3.data").split(QLatin1Char(','));
}
void tst_QDir::setNameFilters()

View File

@ -1994,7 +1994,7 @@ void tst_QFile::longFileName()
QString line = ts.readLine();
QCOMPARE(line, fileName);
}
QString newName = fileName + QLatin1String("1");
QString newName = fileName + QLatin1Char('1');
{
QVERIFY(QFile::copy(fileName, newName));
QFile file(newName);

View File

@ -1065,7 +1065,7 @@ void tst_QFileInfo::consistent()
QFileInfo fi(file);
QCOMPARE(fi.filePath(), expected);
QCOMPARE(fi.dir().path() + "/" + fi.fileName(), expected);
QCOMPARE(fi.dir().path() + QLatin1Char('/') + fi.fileName(), expected);
}

View File

@ -1421,11 +1421,11 @@ void tst_QProcess::spaceArgsTest()
QCOMPARE(actual, args);
#endif
if (program.contains(" "))
program = "\"" + program + "\"";
if (program.contains(QLatin1Char(' ')))
program = QLatin1Char('"') + program + QLatin1Char('"');
if (!stringArgs.isEmpty())
program += QString::fromLatin1(" ") + stringArgs;
program += QLatin1Char(' ') + stringArgs;
errorMessage.clear();
process->start(program);
@ -1479,9 +1479,9 @@ void tst_QProcess::nativeArguments()
char buf[256];
fgets(buf, 256, file);
fclose(file);
QStringList actual = QString::fromLatin1(buf).split("|");
QStringList actual = QString::fromLatin1(buf).split(QLatin1Char('|'));
#else
QStringList actual = QString::fromLatin1(proc.readAll()).split("|");
QStringList actual = QString::fromLatin1(proc.readAll()).split(QLatin1Char('|'));
#endif
QVERIFY(!actual.isEmpty());
// not interested in the program name, it might be different.

View File

@ -211,7 +211,7 @@ static QString settingsPath(const char *path = "")
#else
QString tempPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
#endif
if (tempPath.endsWith("/"))
if (tempPath.endsWith(QLatin1Char('/')))
tempPath.truncate(tempPath.size() - 1);
return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path));
}

View File

@ -1615,18 +1615,18 @@ void tst_QTextStream::forcePoint()
{
QString str;
QTextStream stream(&str);
stream << fixed << forcepoint << 1.0 << " " << 1 << " " << 0 << " " << -1.0 << " " << -1;
stream << fixed << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
QCOMPARE(str, QString("1.000000 1 0 -1.000000 -1"));
str.clear();
stream.seek(0);
stream << scientific << forcepoint << 1.0 << " " << 1 << " " << 0 << " " << -1.0 << " " << -1;
stream << scientific << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
QCOMPARE(str, QString("1.000000e+00 1 0 -1.000000e+00 -1"));
str.clear();
stream.seek(0);
stream.setRealNumberNotation(QTextStream::SmartNotation);
stream << forcepoint << 1.0 << " " << 1 << " " << 0 << " " << -1.0 << " " << -1;
stream << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
QCOMPARE(str, QString("1.00000 1 0 -1.00000 -1"));
}
@ -1636,7 +1636,7 @@ void tst_QTextStream::forceSign()
{
QString str;
QTextStream stream(&str);
stream << forcesign << 1.2 << " " << -1.2 << " " << 0;
stream << forcesign << 1.2 << ' ' << -1.2 << ' ' << 0;
QCOMPARE(str, QString("+1.2 -1.2 +0"));
}
@ -1773,9 +1773,9 @@ void tst_QTextStream::nanInf()
QString s;
QTextStream out(&s);
out << qInf() << " " << -qInf() << " " << qQNaN()
<< uppercasedigits << " "
<< qInf() << " " << -qInf() << " " << qQNaN()
out << qInf() << ' ' << -qInf() << ' ' << qQNaN()
<< uppercasedigits << ' '
<< qInf() << ' ' << -qInf() << ' ' << qQNaN()
<< flush;
QCOMPARE(s, QString("inf -inf nan INF -INF NAN"));
@ -2565,7 +2565,7 @@ void tst_QTextStream::useCase1()
stream.setCodec(QTextCodec::codecForName("ISO-8859-1"));
stream.setAutoDetectUnicode(true);
stream << 4.15 << " " << QByteArray("abc") << " " << QString("ole");
stream << 4.15 << ' ' << QByteArray("abc") << ' ' << QString("ole");
}
file.seek(0);
@ -2601,7 +2601,7 @@ void tst_QTextStream::useCase2()
stream.setCodec(QTextCodec::codecForName("ISO-8859-1"));
stream.setAutoDetectUnicode(true);
stream << 4.15 << " " << QByteArray("abc") << " " << QString("ole");
stream << 4.15 << ' ' << QByteArray("abc") << ' ' << QString("ole");
file.close();
QVERIFY(file.open(QFile::ReadWrite));

View File

@ -103,7 +103,7 @@ static QByteArray prettyList(const T &items)
first = false;
result += prettyPair(it);
}
result += ")";
result += QLatin1Char(')');
return result.toLocal8Bit();
}

View File

@ -233,7 +233,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
{
if (QStringListModel *stringListModel = qobject_cast<QStringListModel *>(model)) {
QString alphabet = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
stringListModel->setStringList( alphabet.split(",") );
stringListModel->setStringList( alphabet.split(QLatin1Char(',')) );
return QModelIndex();
}

View File

@ -1346,14 +1346,14 @@ void tst_QSortFilterProxyModel::buildHierarchy(const QStringList &l, QAbstractIt
QStack<QModelIndex> parent_stack;
for (int i = 0; i < l.count(); ++i) {
QString token = l.at(i);
if (token == "<") { // start table
if (token == QLatin1String("<")) { // start table
++ind;
parent_stack.push(parent);
row_stack.push(row);
parent = m->index(row - 1, 0, parent);
row = 0;
QVERIFY(m->insertColumns(0, 1, parent)); // add column
} else if (token == ">") { // end table
} else if (token == QLatin1String(">")) { // end table
--ind;
parent = parent_stack.pop();
row = row_stack.pop();
@ -1376,14 +1376,14 @@ void tst_QSortFilterProxyModel::checkHierarchy(const QStringList &l, const QAbst
QStack<QModelIndex> parent_stack;
for (int i = 0; i < l.count(); ++i) {
QString token = l.at(i);
if (token == "<") { // start table
if (token == QLatin1String("<")) { // start table
++indent;
parent_stack.push(parent);
row_stack.push(row);
parent = m->index(row - 1, 0, parent);
QVERIFY(parent.isValid());
row = 0;
} else if (token == ">") { // end table
} else if (token == QLatin1String(">")) { // end table
--indent;
parent = parent_stack.pop();
row = row_stack.pop();
@ -1418,7 +1418,7 @@ void tst_QSortFilterProxyModel::filterTable()
filter.setFilterRegExp("9");
for (int i = 0; i < filter.rowCount(); ++i)
QVERIFY(filter.data(filter.index(i, 0)).toString().contains("9"));
QVERIFY(filter.data(filter.index(i, 0)).toString().contains(QLatin1Char('9')));
}
void tst_QSortFilterProxyModel::insertAfterSelect()
@ -2625,7 +2625,7 @@ void tst_QSortFilterProxyModel::staticSorting()
QSortFilterProxyModel proxy;
proxy.setSourceModel(&model);
proxy.setDynamicSortFilter(false);
QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(" ");
QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(QLatin1Char(' '));
// prepare model
QStandardItem *root = model.invisibleRootItem ();
@ -2680,7 +2680,7 @@ void tst_QSortFilterProxyModel::staticSorting()
void tst_QSortFilterProxyModel::dynamicSorting()
{
QStringListModel model1;
const QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(" ");
const QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(QLatin1Char(' '));
model1.setStringList(initial);
QSortFilterProxyModel proxy1;
proxy1.setDynamicSortFilter(false);
@ -3078,7 +3078,7 @@ void tst_QSortFilterProxyModel::appearsAndSort()
void tst_QSortFilterProxyModel::unnecessaryDynamicSorting()
{
QStringListModel model;
const QStringList initial = QString("bravo charlie delta echo").split(" ");
const QStringList initial = QString("bravo charlie delta echo").split(QLatin1Char(' '));
model.setStringList(initial);
QSortFilterProxyModel proxy;
proxy.setDynamicSortFilter(false);
@ -3162,7 +3162,7 @@ private:
void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection()
{
QStringListModel model;
const QStringList initial = QString("bravo charlie delta echo").split(" ");
const QStringList initial = QString("bravo charlie delta echo").split(QLatin1Char(' '));
model.setStringList(initial);
QSortFilterProxyModel proxy;
@ -3196,7 +3196,7 @@ static bool isValid(const QItemSelection &selection)
void tst_QSortFilterProxyModel::mapSelectionFromSource()
{
QStringListModel model;
const QStringList initial = QString("bravo charlie delta echo").split(" ");
const QStringList initial = QString("bravo charlie delta echo").split(QLatin1Char(' '));
model.setStringList(initial);
QSortFilterProxyModel proxy;

View File

@ -2555,8 +2555,8 @@ void tst_QtJson::nesting()
QVERIFY(!doc.isNull());
QCOMPARE(error.error, QJsonParseError::NoError);
json.prepend("[");
json.append("]");
json.prepend('[');
json.append(']');
doc = QJsonDocument::fromJson(json, &error);
QVERIFY(doc.isNull());
@ -2574,8 +2574,8 @@ void tst_QtJson::nesting()
QVERIFY(!doc.isNull());
QCOMPARE(error.error, QJsonParseError::NoError);
json.prepend("[");
json.append("]");
json.prepend('[');
json.append(']');
doc = QJsonDocument::fromJson(json, &error);
QVERIFY(doc.isNull());
@ -2589,7 +2589,7 @@ void tst_QtJson::longStrings()
// in the data structures (for Latin1String in qjson_p.h)
QString s(0x7ff0, 'a');
for (int i = 0x7ff0; i < 0x8010; i++) {
s.append("c");
s.append(QLatin1Char('c'));
QMap <QString, QVariant> map;
map["key"] = s;
@ -2608,7 +2608,7 @@ void tst_QtJson::longStrings()
s = QString(0xfff0, 'a');
for (int i = 0xfff0; i < 0x10010; i++) {
s.append("c");
s.append(QLatin1Char('c'));
QMap <QString, QVariant> map;
map["key"] = s;

View File

@ -96,7 +96,7 @@
static QString sys_qualifiedLibraryName(const QString &fileName)
{
QString appDir = QCoreApplication::applicationDirPath();
return appDir + "/" + PREFIX + fileName + SUFFIX;
return appDir + QLatin1Char('/') + PREFIX + fileName + SUFFIX;
}
QT_FORWARD_DECLARE_CLASS(QLibrary)

View File

@ -3482,7 +3482,7 @@ template<class Container> void foreach_test_arrays(const Container &container)
void tst_Collections::foreach_2()
{
QStringList strlist = QString::fromLatin1("a,b,c,d,e,f,g,h,ih,kl,mn,op,qr,st,uvw,xyz").split(",");
QStringList strlist = QString::fromLatin1("a,b,c,d,e,f,g,h,ih,kl,mn,op,qr,st,uvw,xyz").split(QLatin1Char(','));
foreach_test_arrays(strlist);
foreach_test_arrays(QList<QString>(strlist));
foreach_test_arrays(strlist.toVector());

View File

@ -126,9 +126,9 @@ void tst_QBitArray::size()
for (int j=0; j<len; j++) {
bool b = a[j];
if (b)
S+= "1";
S+= QLatin1Char('1');
else
S+= "0";
S+= QLatin1Char('0');
}
QTEST(S,"res");
}

View File

@ -1984,15 +1984,15 @@ void tst_QByteArray::movablity()
QCOMPARE(array.isEmpty(), newIsEmpty);
QCOMPARE(array.isNull(), newIsNull);
QCOMPARE(array.capacity(), newCapacity);
QVERIFY(array.startsWith("a"));
QVERIFY(array.endsWith("b"));
QVERIFY(array.startsWith('a'));
QVERIFY(array.endsWith('b'));
QCOMPARE(copy.size(), newSize);
QCOMPARE(copy.isEmpty(), newIsEmpty);
QCOMPARE(copy.isNull(), newIsNull);
QCOMPARE(copy.capacity(), newCapacity);
QVERIFY(copy.startsWith("a"));
QVERIFY(copy.endsWith("b"));
QVERIFY(copy.startsWith('a'));
QVERIFY(copy.endsWith('b'));
// try to not crash
array.squeeze();

View File

@ -756,7 +756,7 @@ void tst_QChar::normalization_data()
if (comment >= 0)
line = line.left(comment);
if (line.startsWith("@")) {
if (line.startsWith('@')) {
if (line.startsWith("@Part") && line.size() > 5 && QChar(line.at(5)).isDigit())
part = QChar(line.at(5)).digitValue();
continue;

View File

@ -1047,7 +1047,7 @@ void tst_QDate::fromStringFormat_data()
QTest::newRow("data14") << QString("132") << QString("Md") << invalidDate();
QTest::newRow("data15") << february << QString("MMMM") << QDate(defDate().year(), 2, 1);
QString date = mon + " " + august + " 8 2005";
QString date = mon + QLatin1Char(' ') + august + " 8 2005";
QTest::newRow("data16") << date << QString("ddd MMMM d yyyy") << QDate(2005, 8, 8);
QTest::newRow("data17") << QString("2000:00") << QString("yyyy:yy") << QDate(2000, 1, 1);
QTest::newRow("data18") << QString("1999:99") << QString("yyyy:yy") << QDate(1999, 1, 1);

View File

@ -2096,11 +2096,11 @@ void tst_QDateTime::fromStringStringFormat_data()
QTest::newRow("data9") << QString("101010") << QString("dMyy") << QDateTime(QDate(1910, 10, 10), QTime());
QTest::newRow("data10") << QString("101010") << QString("dMyy") << QDateTime(QDate(1910, 10, 10), QTime());
QTest::newRow("data11") << date << QString("dd MMM yy") << QDateTime(QDate(1910, 10, 10), QTime());
date = fri + " " + december + " 3 2004";
date = fri + QLatin1Char(' ') + december + " 3 2004";
QTest::newRow("data12") << date << QString("ddd MMMM d yyyy") << QDateTime(QDate(2004, 12, 3), QTime());
QTest::newRow("data13") << QString("30.02.2004") << QString("dd.MM.yyyy") << invalidDateTime();
QTest::newRow("data14") << QString("32.01.2004") << QString("dd.MM.yyyy") << invalidDateTime();
date = thu + " " + january + " 2004";
date = thu + QLatin1Char(' ') + january + " 2004";
QTest::newRow("data15") << date << QString("ddd MMMM yyyy") << QDateTime(QDate(2004, 1, 1), QTime());
QTest::newRow("data16") << QString("2005-06-28T07:57:30.001Z")
<< QString("yyyy-MM-ddThh:mm:ss.zZ")

View File

@ -370,7 +370,7 @@ void tst_QLocale::ctor()
&& l.country() == QLocale::exp_country, \
QString("requested: \"" + QString(req_lc) + "\", got: " \
+ QLocale::languageToString(l.language()) \
+ "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \
+ QLatin1Char('/') + QLocale::countryToString(l.country())).toLatin1().constData()); \
QCOMPARE(l, QLocale(QLocale::exp_lang, QLocale::exp_country)); \
QCOMPARE(qHash(l), qHash(QLocale(QLocale::exp_lang, QLocale::exp_country))); \
}
@ -431,8 +431,8 @@ void tst_QLocale::ctor()
&& l.country() == QLocale::exp_country, \
QString("requested: \"" + QString(req_lc) + "\", got: " \
+ QLocale::languageToString(l.language()) \
+ "/" + QLocale::scriptToString(l.script()) \
+ "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \
+ QLatin1Char('/') + QLocale::scriptToString(l.script()) \
+ QLatin1Char('/') + QLocale::countryToString(l.country())).toLatin1().constData()); \
}
TEST_CTOR("zh_CN", Chinese, SimplifiedHanScript, China)
@ -606,7 +606,7 @@ void tst_QLocale::legacyNames()
&& l.country() == QLocale::exp_country, \
QString("requested: \"" + QString(req_lc) + "\", got: " \
+ QLocale::languageToString(l.language()) \
+ "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \
+ QLatin1Char('/') + QLocale::countryToString(l.country())).toLatin1().constData()); \
}
TEST_CTOR("mo_MD", Romanian, Moldova)
@ -1460,9 +1460,9 @@ void tst_QLocale::macDefaultLocale()
if (timeString.contains(QString("GMT"))) {
QString expectedGMTSpecifierBase("GMT");
if (diff >= 0)
expectedGMTSpecifierBase.append("+");
expectedGMTSpecifierBase.append(QLatin1Char('+'));
else
expectedGMTSpecifierBase.append("-");
expectedGMTSpecifierBase.append(QLatin1Char('-'));
QString expectedGMTSpecifier = expectedGMTSpecifierBase + QString("%1").arg(qAbs(diff));
QString expectedGMTSpecifierZeroExtended = expectedGMTSpecifierBase + QString("0%1").arg(qAbs(diff));

View File

@ -1362,7 +1362,7 @@ void tst_QString::indexOf_data()
QString s2;
s2 += QChar(0x3bc);
QTest::newRow( "data58" ) << s1 << s2 << 0 << false << 3;
s2.prepend("C");
s2.prepend(QLatin1Char('C'));
QTest::newRow( "data59" ) << s1 << s2 << 0 << false << 2;
QString veryBigHaystack(500, 'a');

View File

@ -292,7 +292,7 @@ void tst_QStringRef::indexOf_data()
QString s2;
s2 += QChar(0x3bc);
QTest::newRow("data58") << QString(s1) << QString(s2) << 0 << false << 3;
s2.prepend("C");
s2.prepend(QLatin1Char('C'));
QTest::newRow("data59") << QString(s1) << QString(s2) << 0 << false << 2;
QString veryBigHaystack(500, 'a');

View File

@ -119,7 +119,7 @@ static QByteArray makeCanonical(const QString &filename,
if (notation.publicId().isEmpty()) {
writeDtd << " SYSTEM \'";
writeDtd << notation.systemId().toString();
writeDtd << "\'";
writeDtd << '\'';
} else {
writeDtd << " PUBLIC \'";
writeDtd << notation.publicId().toString();
@ -127,10 +127,10 @@ static QByteArray makeCanonical(const QString &filename,
if (!notation.systemId().isEmpty() ) {
writeDtd << " \'";
writeDtd << notation.systemId().toString();
writeDtd << "\'";
writeDtd << '\'';
}
}
writeDtd << ">";
writeDtd << '>';
writeDtd << endl;
}
@ -687,7 +687,7 @@ QByteArray tst_QXmlStream::readFile(const QString &filename)
while (!reader.atEnd()) {
reader.readNext();
writer << reader.tokenString() << "(";
writer << reader.tokenString() << '(';
if (reader.isWhitespace())
writer << " whitespace";
if (reader.isCDATA())
@ -695,42 +695,42 @@ QByteArray tst_QXmlStream::readFile(const QString &filename)
if (reader.isStartDocument() && reader.isStandaloneDocument())
writer << " standalone";
if (!reader.text().isEmpty())
writer << " text=\"" << reader.text().toString() << "\"";
writer << " text=\"" << reader.text().toString() << '"';
if (!reader.processingInstructionTarget().isEmpty())
writer << " processingInstructionTarget=\"" << reader.processingInstructionTarget().toString() << "\"";
writer << " processingInstructionTarget=\"" << reader.processingInstructionTarget().toString() << '"';
if (!reader.processingInstructionData().isEmpty())
writer << " processingInstructionData=\"" << reader.processingInstructionData().toString() << "\"";
writer << " processingInstructionData=\"" << reader.processingInstructionData().toString() << '"';
if (!reader.dtdName().isEmpty())
writer << " dtdName=\"" << reader.dtdName().toString() << "\"";
writer << " dtdName=\"" << reader.dtdName().toString() << '"';
if (!reader.dtdPublicId().isEmpty())
writer << " dtdPublicId=\"" << reader.dtdPublicId().toString() << "\"";
writer << " dtdPublicId=\"" << reader.dtdPublicId().toString() << '"';
if (!reader.dtdSystemId().isEmpty())
writer << " dtdSystemId=\"" << reader.dtdSystemId().toString() << "\"";
writer << " dtdSystemId=\"" << reader.dtdSystemId().toString() << '"';
if (!reader.documentVersion().isEmpty())
writer << " documentVersion=\"" << reader.documentVersion().toString() << "\"";
writer << " documentVersion=\"" << reader.documentVersion().toString() << '"';
if (!reader.documentEncoding().isEmpty())
writer << " documentEncoding=\"" << reader.documentEncoding().toString() << "\"";
writer << " documentEncoding=\"" << reader.documentEncoding().toString() << '"';
if (!reader.name().isEmpty())
writer << " name=\"" << reader.name().toString() << "\"";
writer << " name=\"" << reader.name().toString() << '"';
if (!reader.namespaceUri().isEmpty())
writer << " namespaceUri=\"" << reader.namespaceUri().toString() << "\"";
writer << " namespaceUri=\"" << reader.namespaceUri().toString() << '"';
if (!reader.qualifiedName().isEmpty())
writer << " qualifiedName=\"" << reader.qualifiedName().toString() << "\"";
writer << " qualifiedName=\"" << reader.qualifiedName().toString() << '"';
if (!reader.prefix().isEmpty())
writer << " prefix=\"" << reader.prefix().toString() << "\"";
writer << " prefix=\"" << reader.prefix().toString() << '"';
if (reader.attributes().size()) {
foreach(QXmlStreamAttribute attribute, reader.attributes()) {
writer << endl << " Attribute(";
if (!attribute.name().isEmpty())
writer << " name=\"" << attribute.name().toString() << "\"";
writer << " name=\"" << attribute.name().toString() << '"';
if (!attribute.namespaceUri().isEmpty())
writer << " namespaceUri=\"" << attribute.namespaceUri().toString() << "\"";
writer << " namespaceUri=\"" << attribute.namespaceUri().toString() << '"';
if (!attribute.qualifiedName().isEmpty())
writer << " qualifiedName=\"" << attribute.qualifiedName().toString() << "\"";
writer << " qualifiedName=\"" << attribute.qualifiedName().toString() << '"';
if (!attribute.prefix().isEmpty())
writer << " prefix=\"" << attribute.prefix().toString() << "\"";
writer << " prefix=\"" << attribute.prefix().toString() << '"';
if (!attribute.value().isEmpty())
writer << " value=\"" << attribute.value().toString() << "\"";
writer << " value=\"" << attribute.value().toString() << '"';
writer << " )" << endl;
}
}
@ -738,9 +738,9 @@ QByteArray tst_QXmlStream::readFile(const QString &filename)
foreach(QXmlStreamNamespaceDeclaration namespaceDeclaration, reader.namespaceDeclarations()) {
writer << endl << " NamespaceDeclaration(";
if (!namespaceDeclaration.prefix().isEmpty())
writer << " prefix=\"" << namespaceDeclaration.prefix().toString() << "\"";
writer << " prefix=\"" << namespaceDeclaration.prefix().toString() << '"';
if (!namespaceDeclaration.namespaceUri().isEmpty())
writer << " namespaceUri=\"" << namespaceDeclaration.namespaceUri().toString() << "\"";
writer << " namespaceUri=\"" << namespaceDeclaration.namespaceUri().toString() << '"';
writer << " )" << endl;
}
}
@ -748,11 +748,11 @@ QByteArray tst_QXmlStream::readFile(const QString &filename)
foreach(QXmlStreamNotationDeclaration notationDeclaration, reader.notationDeclarations()) {
writer << endl << " NotationDeclaration(";
if (!notationDeclaration.name().isEmpty())
writer << " name=\"" << notationDeclaration.name().toString() << "\"";
writer << " name=\"" << notationDeclaration.name().toString() << '"';
if (!notationDeclaration.systemId().isEmpty())
writer << " systemId=\"" << notationDeclaration.systemId().toString() << "\"";
writer << " systemId=\"" << notationDeclaration.systemId().toString() << '"';
if (!notationDeclaration.publicId().isEmpty())
writer << " publicId=\"" << notationDeclaration.publicId().toString() << "\"";
writer << " publicId=\"" << notationDeclaration.publicId().toString() << '"';
writer << " )" << endl;
}
}
@ -760,15 +760,15 @@ QByteArray tst_QXmlStream::readFile(const QString &filename)
foreach(QXmlStreamEntityDeclaration entityDeclaration, reader.entityDeclarations()) {
writer << endl << " EntityDeclaration(";
if (!entityDeclaration.name().isEmpty())
writer << " name=\"" << entityDeclaration.name().toString() << "\"";
writer << " name=\"" << entityDeclaration.name().toString() << '"';
if (!entityDeclaration.notationName().isEmpty())
writer << " notationName=\"" << entityDeclaration.notationName().toString() << "\"";
writer << " notationName=\"" << entityDeclaration.notationName().toString() << '"';
if (!entityDeclaration.systemId().isEmpty())
writer << " systemId=\"" << entityDeclaration.systemId().toString() << "\"";
writer << " systemId=\"" << entityDeclaration.systemId().toString() << '"';
if (!entityDeclaration.publicId().isEmpty())
writer << " publicId=\"" << entityDeclaration.publicId().toString() << "\"";
writer << " publicId=\"" << entityDeclaration.publicId().toString() << '"';
if (!entityDeclaration.value().isEmpty())
writer << " value=\"" << entityDeclaration.value().toString() << "\"";
writer << " value=\"" << entityDeclaration.value().toString() << '"';
writer << " )" << endl;
}
}

View File

@ -260,11 +260,11 @@ void tst_QDBusType::isValidArray()
QFETCH(QString, data);
QFETCH(bool, result);
data.prepend("a");
data.prepend(QLatin1Char('a'));
QCOMPARE(bool(q_dbus_signature_validate_single(data.toLatin1(), 0)), result);
QCOMPARE(QDBusUtil::isValidSingleSignature(data), result);
data.prepend("a");
data.prepend(QLatin1Char('a'));
QCOMPARE(bool(q_dbus_signature_validate_single(data.toLatin1(), 0)), result);
QCOMPARE(QDBusUtil::isValidSingleSignature(data), result);
}

View File

@ -141,7 +141,7 @@ void tst_QIcoImageFormat::canRead()
QFETCH(QString, fileName);
QFETCH(int, isValid);
QImageReader reader(m_IconPath + "/" + fileName);
QImageReader reader(m_IconPath + QLatin1Char('/') + fileName);
QCOMPARE(reader.canRead(), (isValid == 0 ? false : true));
}
@ -175,7 +175,7 @@ void tst_QIcoImageFormat::SequentialFile()
QFETCH(QString, fileName);
QFETCH(int, isValid);
QSequentialFile *file = new QSequentialFile(m_IconPath + "/" + fileName);
QSequentialFile *file = new QSequentialFile(m_IconPath + QLatin1Char('/') + fileName);
QVERIFY(file);
QVERIFY(file->open(QFile::ReadOnly));
QImageReader reader(file);
@ -212,7 +212,7 @@ void tst_QIcoImageFormat::imageCount()
QFETCH(QString, fileName);
QFETCH(int, count);
QImageReader reader(m_IconPath + "/" + fileName);
QImageReader reader(m_IconPath + QLatin1Char('/') + fileName);
QCOMPARE(reader.imageCount(), count);
}
@ -240,7 +240,7 @@ void tst_QIcoImageFormat::jumpToNextImage()
QFETCH(QString, fileName);
QFETCH(int, count);
QImageReader reader(m_IconPath + "/" + fileName);
QImageReader reader(m_IconPath + QLatin1Char('/') + fileName);
bool bJumped = reader.jumpToImage(0);
while (bJumped) {
count--;
@ -263,7 +263,7 @@ void tst_QIcoImageFormat::loopCount()
QFETCH(QString, fileName);
QFETCH(int, count);
QImageReader reader(m_IconPath + "/" + fileName);
QImageReader reader(m_IconPath + QLatin1Char('/') + fileName);
QCOMPARE(reader.loopCount(), count);
}
@ -291,7 +291,7 @@ void tst_QIcoImageFormat::nextImageDelay()
QFETCH(QString, fileName);
QFETCH(int, count);
QImageReader reader(m_IconPath + "/" + fileName);
QImageReader reader(m_IconPath + QLatin1Char('/') + fileName);
if (count == -1) {
QCOMPARE(reader.nextImageDelay(), 0);
} else {
@ -320,7 +320,7 @@ void tst_QIcoImageFormat::pngCompression()
QFETCH(int, width);
QFETCH(int, height);
QImageReader reader(m_IconPath + "/" + fileName);
QImageReader reader(m_IconPath + QLatin1Char('/') + fileName);
QImage image;
reader.jumpToImage(index);

View File

@ -158,7 +158,7 @@ private:
// helper to skip an autotest when the given image format is not supported
#define SKIP_IF_UNSUPPORTED(format) do { \
if (!QByteArray(format).isEmpty() && !QImageReader::supportedImageFormats().contains(format)) \
QSKIP("\"" + QByteArray(format) + "\" images are not supported"); \
QSKIP('"' + QByteArray(format) + "\" images are not supported"); \
} while (0)
// Testing get/set functions

View File

@ -96,7 +96,7 @@ private:
// helper to skip an autotest when the given image format is not supported
#define SKIP_IF_UNSUPPORTED(format) do { \
if (!QByteArray(format).isEmpty() && !QImageReader::supportedImageFormats().contains(format)) \
QSKIP("\"" + QByteArray(format) + "\" images are not supported"); \
QSKIP('"' + QByteArray(format) + "\" images are not supported"); \
} while (0)
static void initializePadding(QImage *image)

View File

@ -1613,14 +1613,14 @@ void tst_QStandardItemModel::removeRowsAndColumns()
#define VERIFY_MODEL \
for (int c = 0; c < col_list.count(); c++) \
for (int r = 0; r < row_list.count(); r++) \
QCOMPARE(model.item(r,c)->text() , row_list[r] + "x" + col_list[c]);
QCOMPARE(model.item(r,c)->text() , row_list[r] + QLatin1Char('x') + col_list[c]);
QVector<QString> row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',').toVector();
QVector<QString> col_list = row_list;
QStandardItemModel model;
for (int c = 0; c < col_list.count(); c++)
for (int r = 0; r < row_list.count(); r++)
model.setItem(r, c, new QStandardItem(row_list[r] + "x" + col_list[c]));
model.setItem(r, c, new QStandardItem(row_list[r] + QLatin1Char('x') + col_list[c]));
VERIFY_MODEL
row_list.remove(3);
@ -1642,14 +1642,14 @@ void tst_QStandardItemModel::removeRowsAndColumns()
QList<QStandardItem *> row_taken = model.takeRow(6);
QCOMPARE(row_taken.count(), col_list.count());
for (int c = 0; c < col_list.count(); c++)
QCOMPARE(row_taken[c]->text() , row_list[6] + "x" + col_list[c]);
QCOMPARE(row_taken[c]->text() , row_list[6] + QLatin1Char('x') + col_list[c]);
row_list.remove(6);
VERIFY_MODEL
QList<QStandardItem *> col_taken = model.takeColumn(10);
QCOMPARE(col_taken.count(), row_list.count());
for (int r = 0; r < row_list.count(); r++)
QCOMPARE(col_taken[r]->text() , row_list[r] + "x" + col_list[10]);
QCOMPARE(col_taken[r]->text() , row_list[r] + QLatin1Char('x') + col_list[10]);
col_list.remove(10);
VERIFY_MODEL
}
@ -1661,7 +1661,7 @@ void tst_QStandardItemModel::itemRoleNames()
QStandardItemModel model;
for (int c = 0; c < col_list.count(); c++)
for (int r = 0; r < row_list.count(); r++)
model.setItem(r, c, new QStandardItem(row_list[r] + "x" + col_list[c]));
model.setItem(r, c, new QStandardItem(row_list[r] + QLatin1Char('x') + col_list[c]));
VERIFY_MODEL
QHash<int, QByteArray> newRoleNames;

View File

@ -380,7 +380,7 @@ void tst_QGuiVariant::toString_data()
#ifndef Q_OS_MAC
<< QString( "Ctrl+A" );
#else
<< QString(QChar(0x2318)) + "A";
<< QString(QChar(0x2318)) + QLatin1Char('A');
#endif
QFont font( "times", 12 );

View File

@ -999,16 +999,16 @@ static QByteArray testnameForAxis(const QVector3D &axis)
testname = "null";
} else {
if (axis.x()) {
testname += axis.x() < 0 ? "-" : "+";
testname += "X";
testname += axis.x() < 0 ? '-' : '+';
testname += 'X';
}
if (axis.y()) {
testname += axis.y() < 0 ? "-" : "+";
testname += "Y";
testname += axis.y() < 0 ? '-' : '+';
testname += 'Y';
}
if (axis.z()) {
testname += axis.z() < 0 ? "-" : "+";
testname += "Z";
testname += axis.z() < 0 ? '-' : '+';
testname += 'Z';
}
}
return testname;

View File

@ -185,7 +185,7 @@ static void debug(const QVector<QCss::Symbol> &symbols, int index = -1)
{
qDebug() << "all symbols:";
for (int i = 0; i < symbols.count(); ++i)
qDebug() << "(" << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
qDebug() << '(' << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem();
if (index != -1)
qDebug() << "failure at index" << index;
}
@ -1340,7 +1340,7 @@ void tst_QCssParser::shorthandBackgroundProperty()
QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
css.prepend("dummy {");
css.append("}");
css.append(QLatin1Char('}'));
QCss::Parser parser(css);
QCss::StyleSheet sheet;
@ -1500,7 +1500,7 @@ void tst_QCssParser::gradient()
QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>")));
css.prepend("dummy {");
css.append("}");
css.append(QLatin1Char('}'));
QCss::Parser parser(css);
QCss::StyleSheet sheet;
@ -1560,7 +1560,7 @@ void tst_QCssParser::extractFontFamily()
{
QFETCH(QString, css);
css.prepend("dummy {");
css.append("}");
css.append(QLatin1Char('}'));
QCss::Parser parser(css);
QCss::StyleSheet sheet;
@ -1618,7 +1618,7 @@ void tst_QCssParser::extractBorder()
QFETCH(QColor, expectedTopColor);
css.prepend("dummy {");
css.append("}");
css.append(QLatin1Char('}'));
QCss::Parser parser(css);
QCss::StyleSheet sheet;

View File

@ -1123,10 +1123,10 @@ void tst_QTextLayout::boundingRectTopLeft()
void tst_QTextLayout::graphemeBoundaryForSurrogatePairs()
{
QString txt;
txt.append("a");
txt.append(QLatin1Char('a'));
txt.append(0xd87e);
txt.append(0xdc25);
txt.append("b");
txt.append(QLatin1Char('b'));
QTextLayout layout(txt);
QTextEngine *engine = layout.engine();
const QCharAttributes *attrs = engine->attributes();

View File

@ -130,7 +130,7 @@ struct ShapeTable {
static void prepareShapingTest(const QFont &font, const ShapeTable *shape_table)
{
for (const ShapeTable *s = shape_table; s->unicode[0]; ++s) {
QByteArray testName = font.family().toLatin1() + ":";
QByteArray testName = font.family().toLatin1() + ':';
QString string;
for (const ushort *u = s->unicode; *u; ++u) {
string.append(QChar(*u));

View File

@ -2048,10 +2048,10 @@ bool tst_QFtp::dirExists( const QString &host, quint16 port, const QString &user
addCommand( QFtp::ConnectToHost, ftp->connectToHost( host, port ) );
addCommand( QFtp::Login, ftp->login( user, password ) );
if ( dirToCreate.startsWith( "/" ) )
if ( dirToCreate.startsWith( QLatin1Char('/') ) )
addCommand( QFtp::Cd, ftp->cd( dirToCreate ) );
else
addCommand( QFtp::Cd, ftp->cd( cdDir + "/" + dirToCreate ) );
addCommand( QFtp::Cd, ftp->cd( cdDir + QLatin1Char('/') + dirToCreate ) );
addCommand( QFtp::Close, ftp->close() );
inFileDirExistsFunction = true;

View File

@ -2780,7 +2780,7 @@ void tst_QNetworkReply::postToHttpsMultipart()
// hack for testing the setting of the content-type header by hand:
if (contentType == "custom") {
QByteArray contentType("multipart/custom; boundary=\"" + multiPart->boundary() + "\"");
QByteArray contentType("multipart/custom; boundary=\"" + multiPart->boundary() + '"');
request.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
}
@ -2932,7 +2932,7 @@ void tst_QNetworkReply::connectToIPv6Address()
QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QByteArray content = reply->readAll();
//qDebug() << server.receivedData;
QByteArray hostinfo = "\r\nHost: " + hostfield + ":" + QByteArray::number(server.serverPort()) + "\r\n";
QByteArray hostinfo = "\r\nHost: " + hostfield + ':' + QByteArray::number(server.serverPort()) + "\r\n";
QVERIFY(server.receivedData.contains(hostinfo));
QCOMPARE(content, dataToSend);
QCOMPARE(reply->url(), request.url());
@ -4943,7 +4943,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
const int allowedDeviation = 16; // TODO find out why the send rate is 13% faster currently
const int minRate = rate * 1024 * (100-allowedDeviation) / 100;
const int maxRate = rate * 1024 * (100+allowedDeviation) / 100;
qDebug() << minRate << "<="<< server.transferRate << "<=" << maxRate << "?";
qDebug() << minRate << "<="<< server.transferRate << "<=" << maxRate << '?';
// The test takes too long to run if sending enough data to overwhelm the
// reciever's kernel buffers.
//QEXPECT_FAIL("http+limited", "Limiting is broken right now, check QTBUG-15065", Continue);
@ -5519,7 +5519,7 @@ void tst_QNetworkReply::sendCookies_data()
list.clear();
cookie = QNetworkCookie("a", "b");
cookie.setPath("/");
cookie.setDomain("." + QtNetworkSettings::serverDomainName());
cookie.setDomain(QLatin1Char('.') + QtNetworkSettings::serverDomainName());
list << cookie;
QTest::newRow("domain-match") << list << "a=b";
@ -5852,7 +5852,7 @@ void tst_QNetworkReply::httpConnectionCount()
QCoreApplication::instance()->processEvents();
for (int i = 0; i < 10; i++) {
QNetworkRequest request (QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/" + QString::number(i)));
QNetworkRequest request (QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + QLatin1Char('/') + QString::number(i)));
QNetworkReply* reply = manager.get(request);
reply->setParent(&server);
}

View File

@ -141,7 +141,7 @@ void tst_QNetworkInterface::dump()
s.nospace() << ": " << qPrintable(e.ip().toString());
if (!e.netmask().isNull())
s.nospace() << '/' << e.prefixLength()
<< " (" << qPrintable(e.netmask().toString()) << ")";
<< " (" << qPrintable(e.netmask().toString()) << ')';
if (!e.broadcast().isNull())
s.nospace() << " broadcast " << qPrintable(e.broadcast().toString());
}

View File

@ -534,7 +534,7 @@ void tst_QLocalSocket::sendData()
if (server.hasPendingConnections()) {
QString testLine = "test";
for (int i = 0; i < 50000; ++i)
testLine += "a";
testLine += QLatin1Char('a');
QLocalSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState);
@ -1205,7 +1205,7 @@ void tst_QLocalSocket::verifyListenWithDescriptor()
QVERIFY2(server.fullServerName().at(0) == at, "abstract sockets should start with a '@'");
} else {
QCOMPARE(server.fullServerName(), path);
if (path.contains(QLatin1String("/"))) {
if (path.contains(QLatin1Char('/'))) {
QVERIFY2(server.serverName() == path.mid(path.lastIndexOf(QLatin1Char('/'))+1), "server name invalid short name");
} else {
QVERIFY2(server.serverName() == path, "servier name doesn't match the path provided");

View File

@ -1776,7 +1776,7 @@ void tst_QTcpSocket::atEnd()
// Test server must use some vsFTPd 2.x.x version
QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting));
QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting));
QVERIFY2(greeting.endsWith(")"), qPrintable(greeting));
QVERIFY2(greeting.endsWith(QLatin1Char(')')), qPrintable(greeting));
delete socket;
}

View File

@ -1064,7 +1064,7 @@ QString tst_QSslCertificate::toString(const QList<QSslError>& errors)
QStringList errorStrings;
foreach (const QSslError& error, errors) {
errorStrings.append(QLatin1String("\"") + error.errorString() + QLatin1String("\""));
errorStrings.append(QLatin1Char('"') + error.errorString() + QLatin1Char('"'));
}
return QLatin1String("[ ") + errorStrings.join(QLatin1String(", ")) + QLatin1String(" ]");

View File

@ -149,9 +149,10 @@ void atWrapper::ftpMgetDone( bool error)
if ( mgetDirList.size() > 1 )
for ( int i = 1; i < mgetDirList.size(); ++i )
{
file = new QFile( QString( output ) + "/" + mgetDirList.at( 0 ) + "/" + mgetDirList.at( i ) );
file = new QFile( QString( output ) + QLatin1Char('/') + mgetDirList.at( 0 )
+ QLatin1Char('/') + mgetDirList.at( i ) );
if (file->open(QIODevice::WriteOnly)) {
ftp.get( ftpBaseDir + "/" + mgetDirList.at( 0 ) + "/" + mgetDirList.at( i ), file );
ftp.get( ftpBaseDir + QLatin1Char('/') + mgetDirList.at( 0 ) + QLatin1Char('/') + mgetDirList.at( i ), file );
ftp.list(); //Only there to fill up a slot in the pendingCommands queue.
while ( ftp.hasPendingCommands() )
QCoreApplication::instance()->processEvents();
@ -192,11 +193,11 @@ bool atWrapper::setupFTP()
QString dir = "";
ftpMkDir( ftpBaseDir );
ftpBaseDir += "/" + QLibraryInfo::buildKey();
ftpBaseDir += QLatin1Char('/') + QLibraryInfo::buildKey();
ftpMkDir( ftpBaseDir );
ftpBaseDir += "/" + QString( qVersion() );
ftpBaseDir += QLatin1Char('/') + QString( qVersion() );
ftpMkDir( ftpBaseDir );
@ -209,9 +210,9 @@ bool atWrapper::setupFTP()
{
i.next();
//qDebug() << "Creating dir with key:" << i.key();
ftpMkDir( ftpBaseDir + "/" + QString( i.key() ) + ".failed" );
ftpMkDir( ftpBaseDir + "/" + QString( i.key() ) + ".diff" );
if (!ftpMkDir( ftpBaseDir + "/" + QString( i.key() ) + ".baseline" ))
ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".failed" );
ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".diff" );
if (!ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".baseline" ))
haveBaseline = false;
}
@ -226,7 +227,7 @@ bool atWrapper::setupFTP()
{
j.next();
rmDirList.clear();
rmDirList << ftpBaseDir + "/" + j.key() + ".failed" + "/";
rmDirList << ftpBaseDir + QLatin1Char('/') + j.key() + ".failed/";
ftpRmDir( j.key() + ".failed" );
ftp.rmdir( j.key() + ".failed" );
ftp.mkdir( j.key() + ".failed" );
@ -236,7 +237,7 @@ bool atWrapper::setupFTP()
QCoreApplication::instance()->processEvents();
rmDirList.clear();
rmDirList << ftpBaseDir + "/" + j.key() + ".diff" + "/";
rmDirList << ftpBaseDir + QLatin1Char('/') + j.key() + ".diff/";
ftpRmDir( j.key() + ".diff" );
ftp.rmdir( j.key() + ".diff" );
ftp.mkdir( j.key() + ".diff" );
@ -396,7 +397,7 @@ void atWrapper::createBaseline()
for (int n = 0; n < list.size(); n++)
{
QFileInfo fileInfo = list.at( n );
QFile file( QString( output ) + "/" + i.key() + "/" + fileInfo.fileName() );
QFile file( QString( output ) + QLatin1Char('/') + i.key() + QLatin1Char('/') + fileInfo.fileName() );
file.open( QIODevice::ReadOnly );
QByteArray fileData = file.readAll();
//qDebug() << "Sending up:" << fileInfo.fileName() << "with file size" << fileData.size();
@ -470,9 +471,9 @@ bool atWrapper::diff( QString basedir, QString dir, QString target )
//Comparing the two specified files, and then uploading them to
//the ftp server if they differ
basedir += "/" + dir;
basedir += QLatin1Char('/') + dir;
QString one = basedir + ".baseline/" + target;
QString two = basedir + "/" + target;
QString two = basedir + QLatin1Char('/') + target;
QFile file( one );
@ -517,7 +518,7 @@ void atWrapper::uploadDiff( QString basedir, QString dir, QString filename )
qDebug() << basedir;
QImage im1( basedir + ".baseline/" + filename );
QImage im2( basedir + "/" + filename );
QImage im2( basedir + QLatin1Char('/') + filename );
QImage im3(im1.size(), QImage::Format_ARGB32);
@ -591,16 +592,16 @@ bool atWrapper::loadConfig( QString path )
QDir::current().mkdir( output );
output += "/" + QLibraryInfo::buildKey();
output += QLatin1Char('/') + QLibraryInfo::buildKey();
QDir::current().mkdir( output );
output += "/" + QString( qVersion() );
output += QLatin1Char('/') + QString( qVersion() );
QDir::current().mkdir( output );
ftpBaseDir += "/" + QHostInfo::localHostName().split( "." ).first();
ftpBaseDir += QLatin1Char('/') + QHostInfo::localHostName().split( QLatin1Char('.') ).first();
/*

View File

@ -222,46 +222,46 @@ QDebug operator<<(QDebug d, const QNativeEvent &e)
QTextStream &operator<<(QTextStream &s, QNativeEvent *e)
{
return s << e->eventId << " " << e->modifiers << " QNativeEvent";
return s << e->eventId << ' ' << e->modifiers << " QNativeEvent";
}
QTextStream &operator<<(QTextStream &s, QNativeMouseEvent *e)
{
return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->modifiers << " " << e->toString();
return s << e->eventId << ' ' << e->globalPos.x() << ' ' << e->globalPos.y() << ' ' << e->modifiers << ' ' << e->toString();
}
QTextStream &operator<<(QTextStream &s, QNativeMouseMoveEvent *e)
{
return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->modifiers << " " << e->toString();
return s << e->eventId << ' ' << e->globalPos.x() << ' ' << e->globalPos.y() << ' ' << e->modifiers << ' ' << e->toString();
}
QTextStream &operator<<(QTextStream &s, QNativeMouseButtonEvent *e)
{
return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->button
<< " " << e->clickCount << " " << e->modifiers << " " << e->toString();
return s << e->eventId << ' ' << e->globalPos.x() << ' ' << e->globalPos.y() << ' ' << e->button
<< ' ' << e->clickCount << ' ' << e->modifiers << ' ' << e->toString();
}
QTextStream &operator<<(QTextStream &s, QNativeMouseDragEvent *e)
{
return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->button << " " << e->clickCount
<< " " << e->modifiers << " " << e->toString();
return s << e->eventId << ' ' << e->globalPos.x() << ' ' << e->globalPos.y() << ' ' << e->button << ' ' << e->clickCount
<< ' ' << e->modifiers << ' ' << e->toString();
}
QTextStream &operator<<(QTextStream &s, QNativeMouseWheelEvent *e)
{
return s << e->eventId << " " << e->globalPos.x() << " " << e->globalPos.y() << " " << e->delta
<< " " << e->modifiers << " " << e->toString();
return s << e->eventId << ' ' << e->globalPos.x() << ' ' << e->globalPos.y() << ' ' << e->delta
<< ' ' << e->modifiers << ' ' << e->toString();
}
QTextStream &operator<<(QTextStream &s, QNativeKeyEvent *e)
{
return s << e->eventId << " " << e->press << " " << e->nativeKeyCode << " " << e->character
<< " " << e->modifiers << " " << e->toString();
return s << e->eventId << ' ' << e->press << ' ' << e->nativeKeyCode << ' ' << e->character
<< ' ' << e->modifiers << ' ' << e->toString();
}
QTextStream &operator<<(QTextStream &s, QNativeModifierEvent *e)
{
return s << e->eventId << " " << e->modifiers << " " << e->nativeKeyCode << " " << e->toString();
return s << e->eventId << ' ' << e->modifiers << ' ' << e->nativeKeyCode << ' ' << e->toString();
}

View File

@ -72,7 +72,7 @@ protected:
currentName.chop(1);
ok &= (msg.contains(", " + currentName) || msg.contains(", 0x0"));
}
ok &= msg.endsWith(")");
ok &= msg.endsWith(QLatin1Char(')'));
QVERIFY2(ok, (QString::fromLatin1("Message is not correctly finished: '") + msg + '\'').toLatin1().constData());
}

View File

@ -119,7 +119,7 @@ inline static QString qTableName(const QString& prefix, QSqlDatabase db)
QString tableStr;
if (db.driverName().toLower().contains("ODBC"))
tableStr += QLatin1String("_odbc");
return fixupTableName(QString(db.driver()->escapeIdentifier(prefix + tableStr + "_" +
return fixupTableName(QString(db.driver()->escapeIdentifier(prefix + tableStr + QLatin1Char('_') +
qGetHostName(), QSqlDriver::TableName)),db);
}
@ -219,12 +219,12 @@ public:
}
// construct a stupid unique name
QString cName = QString::number( counter++ ) + "_" + driver + "@";
QString cName = QString::number( counter++ ) + QLatin1Char('_') + driver + QLatin1Char('@');
cName += host.isEmpty() ? dbName : host;
if ( port > 0 )
cName += ":" + QString::number( port );
cName += QLatin1Char(':') + QString::number( port );
db = QSqlDatabase::addDatabase( driver, cName );
@ -364,7 +364,7 @@ public:
// for debugging only: outputs the connection as string
static QString dbToString( const QSqlDatabase db )
{
QString res = db.driverName() + "@";
QString res = db.driverName() + QLatin1Char('@');
if ( db.driverName().startsWith( "QODBC" ) || db.driverName().startsWith( "QOCI" ) ) {
res += db.databaseName();
@ -373,7 +373,7 @@ public:
}
if ( db.port() > 0 ) {
res += ":" + QString::number( db.port() );
res += QLatin1Char(':') + QString::number( db.port() );
}
return res;
@ -522,7 +522,7 @@ public:
result += '\'';
if(!err.driverText().isEmpty())
result += err.driverText() + "' || '";
result += err.databaseText() + "'";
result += err.databaseText() + QLatin1Char('\'');
return result.toLocal8Bit();
}
@ -534,7 +534,7 @@ public:
result += '\'';
if(!err.driverText().isEmpty())
result += err.driverText() + "' || '";
result += err.databaseText() + "'";
result += err.databaseText() + QLatin1Char('\'');
return result.toLocal8Bit();
}

View File

@ -217,7 +217,7 @@ struct FieldDef {
{
QString rt = typeName;
rt.replace(QRegExp("\\s"), QString("_"));
int i = rt.indexOf("(");
int i = rt.indexOf(QLatin1Char('('));
if (i == -1)
i = rt.length();
if (i > 20)

View File

@ -79,7 +79,7 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db)
tst_Databases::safeDropTable( db, relTEST1 );
QString doubleField = (dbType == QSqlDriver::SQLite) ? "more_data double" : "more_data double(8,7)";
QVERIFY_SQL( q, exec("create table " + relTEST1 +
" (id int not null primary key, name varchar(20), title_key int, another_title_key int, " + doubleField + ")"));
" (id int not null primary key, name varchar(20), title_key int, another_title_key int, " + doubleField + QLatin1Char(')')));
QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(1, 'harry', 1, 2, 1.234567)"));
QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(2, 'trond', 2, 1, 8.901234)"));
QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(3, 'vohi', 1, 2, 5.678901)"));

View File

@ -959,14 +959,14 @@ void tst_QSqlQuery::value()
if (dbType == QSqlDriver::Interbase)
QVERIFY( q.value( 1 ).toString().startsWith( "VarChar" + QString::number( i ) ) );
else if ( q.value( 1 ).toString().right( 1 ) == " " )
else if ( q.value( 1 ).toString().endsWith(QLatin1Char(' ')))
QCOMPARE( q.value( 1 ).toString(), ( "VarChar" + QString::number( i ) + " " ) );
else
QCOMPARE( q.value( 1 ).toString(), ( "VarChar" + QString::number( i ) ) );
if (dbType == QSqlDriver::Interbase)
QVERIFY( q.value( 2 ).toString().startsWith( "Char" + QString::number( i ) ) );
else if ( q.value( 2 ).toString().right( 1 ) != " " )
else if (!q.value( 2 ).toString().endsWith(QLatin1Char(' ')))
QCOMPARE( q.value( 2 ).toString(), ( "Char" + QString::number( i ) ) );
else
QCOMPARE( q.value( 2 ).toString(), ( "Char" + QString::number( i ) + " " ) );
@ -3145,7 +3145,7 @@ void tst_QSqlQuery::sqlServerReturn0()
"SELECT * FROM "+tableName+" WHERE ID = 2 "
"RETURN 0"));
QVERIFY_SQL(q, exec("{CALL "+procName+"}"));
QVERIFY_SQL(q, exec("{CALL " + procName + QLatin1Char('}')));
QVERIFY_SQL(q, next());
}
@ -3162,7 +3162,7 @@ void tst_QSqlQuery::QTBUG_551()
TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\
TYPE VCType IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;\n\
PROCEDURE P (Inp IN IntType, Outp OUT VCType);\n\
END "+pkgname+";"));
END "+ pkgname + QLatin1Char(';')));
QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE BODY "+pkgname+" IS\n\
PROCEDURE P (Inp IN IntType, Outp OUT VCType)\n\
@ -3172,7 +3172,7 @@ void tst_QSqlQuery::QTBUG_551()
Outp(2) := '2. Value is ' ||TO_CHAR(Inp(2));\n\
Outp(3) := '3. Value is ' ||TO_CHAR(Inp(3));\n\
END p;\n\
END "+pkgname+";"));
END " + pkgname + QLatin1Char(';')));
QVariantList inLst, outLst, res_outLst;
@ -3310,7 +3310,7 @@ void tst_QSqlQuery::QTBUG_6421()
QVERIFY_SQL(q, exec("create index INDEX2 on "+tableName+" (COL2 desc)"));
QVERIFY_SQL(q, exec("create index INDEX3 on "+tableName+" (COL3 desc)"));
q.setForwardOnly(true);
QVERIFY_SQL(q, exec("select COLUMN_EXPRESSION from ALL_IND_EXPRESSIONS where TABLE_NAME='"+tableName+"'"));
QVERIFY_SQL(q, exec("select COLUMN_EXPRESSION from ALL_IND_EXPRESSIONS where TABLE_NAME='" + tableName + QLatin1Char('\'')));
QVERIFY_SQL(q, next());
QCOMPARE(q.value(0).toString(), QLatin1String("\"COL1\""));
QVERIFY_SQL(q, next());
@ -3338,7 +3338,7 @@ void tst_QSqlQuery::QTBUG_6618()
"begin\n"
" raiserror('" + errorString + "', 16, 1)\n"
"end\n" ));
q.exec("{call " + qTableName("tst_raiseError", __FILE__, db) + "}");
q.exec("{call " + qTableName("tst_raiseError", __FILE__, db) + QLatin1Char('}'));
QVERIFY(q.lastError().text().contains(errorString));
}
@ -3430,7 +3430,7 @@ void tst_QSqlQuery::QTBUG_21884()
QStringList stList;
QString tableName(qTableName("bug21884", __FILE__, db));
stList << "create table " + tableName + "(id integer primary key, note string)";
stList << "select * from " + tableName + ";";
stList << "select * from " + tableName + QLatin1Char(';');
stList << "select * from " + tableName + "; \t\n\r";
stList << "drop table " + tableName;
@ -3984,7 +3984,7 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const
{
QSqlQuery q(db);
QVERIFY_SQL(q, exec("DROP TABLE IF EXISTS " + tableName));
QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ")"));
QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ')'));
const int steps = 20;
const T increment = max / steps - min / steps;
@ -4001,7 +4001,7 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const
q.bindValue(0, v);
QVERIFY_SQL(q, exec());
} else {
QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + ")"));
QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + QLatin1Char(')')));
}
values[i] = v;
v += increment;

View File

@ -1115,7 +1115,7 @@ void tst_QSqlRelationalTableModel::casing()
QCOMPARE( rec.count(), 0);
//try an owner that does exist
rec = db.driver()->record(db.userName() + "." + qTableName("CASETEST1", db).toUpper());
rec = db.driver()->record(db.userName() + QLatin1Char('.') + qTableName("CASETEST1", db).toUpper());
QCOMPARE( rec.count(), 4);
}
QSqlRecord rec = db.driver()->record(qTableName("CASETEST1", db).toUpper());
@ -1464,13 +1464,13 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest()
QSqlQuery q(db);
QVERIFY_SQL(q, exec("create schema " + qTableName("QTBUG_5373", __FILE__, db)));
QVERIFY_SQL(q, exec("create schema " + qTableName("QTBUG_5373_s2", __FILE__, db)));
QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373", __FILE__, db) + "." + qTableName("document", __FILE__, db) +
QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373", __FILE__, db) + QLatin1Char('.') + qTableName("document", __FILE__, db) +
"(document_id int primary key, relatingid int, userid int)"));
QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db) +
QVERIFY_SQL(q, exec("create table " + qTableName("QTBUG_5373_s2", __FILE__, db) + QLatin1Char('.') + qTableName("user", __FILE__, db) +
"(userid int primary key, username char(40))"));
model.setTable(qTableName("QTBUG_5373", __FILE__, db) + "." + qTableName("document", __FILE__, db));
model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db), "userid", "username"));
model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + "." + qTableName("user", __FILE__, db), "userid", "username"));
model.setTable(qTableName("QTBUG_5373", __FILE__, db) + QLatin1Char('.') + qTableName("document", __FILE__, db));
model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + QLatin1Char('.') + qTableName("user", __FILE__, db), "userid", "username"));
model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__, db) + QLatin1Char('.') + qTableName("user", __FILE__, db), "userid", "username"));
QVERIFY_SQL(model, select());
model.setJoinMode(QSqlRelationalTableModel::LeftJoin);
@ -1515,14 +1515,14 @@ void tst_QSqlRelationalTableModel::relationOnFirstColumn()
//prepare test1 table
QSqlQuery q(db);
QVERIFY_SQL(q, exec("CREATE TABLE " + testTable1 + " (val1 INTEGER, id1 INTEGER PRIMARY KEY);"));
QVERIFY_SQL(q, exec("DELETE FROM " + testTable1 + ";"));
QVERIFY_SQL(q, exec("DELETE FROM " + testTable1 + QLatin1Char(';')));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable1 + " (id1, val1) VALUES(1, 10);"));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable1 + " (id1, val1) VALUES(2, 20);"));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable1 + " (id1, val1) VALUES(3, 30);"));
//prepare test2 table
QVERIFY_SQL(q, exec("CREATE TABLE " + testTable2 + " (id INTEGER PRIMARY KEY, name TEXT);"));
QVERIFY_SQL(q, exec("DELETE FROM " + testTable2 + ";"));
QVERIFY_SQL(q, exec("DELETE FROM " + testTable2 + QLatin1Char(';')));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable2 + " (id, name) VALUES (10, 'Hervanta');"));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable2 + " (id, name) VALUES (20, 'Keskusta');"));
QVERIFY_SQL(q, exec("INSERT INTO " + testTable2 + " (id, name) VALUES (30, 'Annala');"));

View File

@ -1987,7 +1987,7 @@ void tst_QSqlTableModel::tableModifyWithBlank()
//set a filter on the table so the only record we get is the one we just made
//I could just do another setData command, but I want to make sure the TableModel
//matches exactly what is stored in the database
model.setFilter("column1='"+timeString+"'"); //filter to get just the newly entered row
model.setFilter("column1='" + timeString + QLatin1Char('\'')); //filter to get just the newly entered row
QVERIFY_SQL(model, select());
//Make sure we only get one record, and that it is the one we just made

View File

@ -296,7 +296,7 @@ bool TestCompiler::make( const QString &workPath, const QString &target, bool ex
bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version )
{
QFileInfo f(destDir + "/" + targetName(buildType, exeName, version));
QFileInfo f(destDir + QLatin1Char('/') + targetName(buildType, exeName, version));
return f.exists();
}

View File

@ -956,7 +956,7 @@ void tst_QFiledialog::selectFiles()
QListView* listView = fd.findChild<QListView*>("listView");
QVERIFY(listView);
for (int i = 0; i < list.count(); ++i) {
fd.selectFile(fd.directory().path() + "/" + list.at(i));
fd.selectFile(fd.directory().path() + QLatin1Char('/') + list.at(i));
QTRY_VERIFY(!listView->selectionModel()->selectedRows().isEmpty());
toSelect.append(listView->selectionModel()->selectedRows().last());
}

View File

@ -514,7 +514,7 @@ protected:
path = parentIndex.child(source_row,0).data(Qt::DisplayRole).toString();
do {
path = parentIndex.data(Qt::DisplayRole).toString() + "/" + path;
path = parentIndex.data(Qt::DisplayRole).toString() + QLatin1Char('/') + path;
parentIndex = parentIndex.parent();
} while(parentIndex.isValid());
@ -897,7 +897,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
#else
QTest::qWait(500);
#endif
QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QChar('/') + QLatin1String("g"));
QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QLatin1String("/g"));
QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
fd3.restoreState(fd.saveState());

View File

@ -1097,7 +1097,7 @@ void tst_QFileSystemModel::permissions() // checks QTBUG-20503
QFETCH(bool, readOnly);
const QString tmp = flatDirTestPath;
const QString file = tmp + '/' + "f";
const QString file = tmp + QLatin1String("/f");
QVERIFY(createFiles(tmp, QStringList() << "f"));
QVERIFY(QFile::setPermissions(file, QFile::Permissions(permissions)));

View File

@ -606,7 +606,7 @@ void tst_QMessageBox::detailsButtonText()
QAbstractButton* btn = NULL;
foreach(btn, list) {
if (btn && (btn->inherits("QPushButton"))) {
if (btn->text().remove("&") != QMessageBox::tr("OK")
if (btn->text().remove(QLatin1Char('&')) != QMessageBox::tr("OK")
&& btn->text() != QMessageBox::tr("Show Details...")) {
QFAIL(qPrintable(QString("Unexpected messagebox button text: %1").arg(btn->text())));
}

View File

@ -547,8 +547,8 @@ void tst_QWizard::setDefaultProperty()
// make sure the data structure is reasonable
for (int i = 0; i < 200000; ++i) {
wizard.setDefaultProperty("QLineEdit", QByteArray("x" + QByteArray::number(i)).constData(), 0);
wizard.setDefaultProperty("QLabel", QByteArray("y" + QByteArray::number(i)).constData(), 0);
wizard.setDefaultProperty("QLineEdit", QByteArray('x' + QByteArray::number(i)).constData(), 0);
wizard.setDefaultProperty("QLabel", QByteArray('y' + QByteArray::number(i)).constData(), 0);
}
}
@ -2115,7 +2115,7 @@ void tst_QWizard::combinations()
}
if (minSizeTest)
qDebug() << "minimum sizes" << reason.latin1() << ";" << wizard.minimumSizeHint()
qDebug() << "minimum sizes" << reason.latin1() << ';' << wizard.minimumSizeHint()
<< otor.latin1() << refMinSize;
if (imageTest)

View File

@ -416,14 +416,14 @@ void tst_QDirModel::rowsAboutToBeRemoved_data()
bool tst_QDirModel::rowsAboutToBeRemoved_init(const QString &test_path, const QStringList &initial_files)
{
QString path = QDir::currentPath() + "/" + test_path;
QString path = QDir::currentPath() + QLatin1Char('/') + test_path;
if (!QDir::current().mkdir(test_path) && false) { // FIXME
qDebug() << "failed to create dir" << path;
return false;
}
for (int i = 0; i < initial_files.count(); ++i) {
QFile file(path + "/" + initial_files.at(i));
QFile file(path + QLatin1Char('/') + initial_files.at(i));
if (!file.open(QIODevice::WriteOnly)) {
qDebug() << "failed to open file" << initial_files.at(i);
return false;
@ -443,7 +443,7 @@ bool tst_QDirModel::rowsAboutToBeRemoved_init(const QString &test_path, const QS
bool tst_QDirModel::rowsAboutToBeRemoved_cleanup(const QString &test_path)
{
QString path = QDir::currentPath() + "/" + test_path;
QString path = QDir::currentPath() + QLatin1Char('/') + test_path;
QDir dir(path, "*", QDir::SortFlags(QDir::Name|QDir::IgnoreCase), QDir::Files);
QStringList files = dir.entryList();
@ -584,8 +584,8 @@ void tst_QDirModel::filePath()
QString path = SRCDIR;
#else
QString path = QFileInfo(SRCDIR).absoluteFilePath();
if (!path.endsWith("/"))
path += "/";
if (!path.endsWith(QLatin1Char('/')))
path += QLatin1Char('/');
#endif
QCOMPARE(model.filePath(index), path + QString( "test.lnk"));
model.setResolveSymlinks(true);

View File

@ -2492,7 +2492,7 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare
QString msg = "semantic problem at " + QString(__FILE__) + " (" + sline + ")";
msg += "\nThe *expected* result was : {" + istr(x[0]) + istr(x[1]) + istr(x[2]) + istr(x[3])
+ istr(x[4]) + istr(x[5]) + istr(x[6], false) + "}";
+ istr(x[4]) + istr(x[5]) + istr(x[6], false) + QLatin1Char('}');
msg += "\nThe calculated result was : {";
msg += istr(chk_visual) + istr(chk_logical) + istr(chk_sizes) + istr(chk_hidden_size)
+ istr(chk_lookup_visual) + istr(chk_lookup_logical) + istr(header_lenght, false) + "};";
@ -2570,7 +2570,7 @@ void tst_QHeaderView::additionalInit()
for (int i = 0; i < model->rowCount(); ++i) {
model->setData(model->index(i, 0), QVariant(i));
s.setNum(i);
s += ".";
s += QLatin1Char('.');
s += 'a' + (i % 25);
model->setData(model->index(i, 1), QVariant(s));
}

View File

@ -2083,7 +2083,7 @@ void tst_QListView::taskQTBUG_12308_wrongFlowLayout()
QListWidgetItem *item = new QListWidgetItem();
item->setText(QString("Item %L1").arg(i));
lw.addItem(item);
if (!item->text().contains(QString::fromLatin1("1")))
if (!item->text().contains(QLatin1Char('1')))
item->setHidden(true);
}
lw.show();

View File

@ -4286,7 +4286,7 @@ void tst_QTreeView::testInitialFocus()
{
QTreeWidget treeWidget;
treeWidget.setColumnCount(5);
new QTreeWidgetItem(&treeWidget, QStringList(QString("1;2;3;4;5").split(";")));
new QTreeWidgetItem(&treeWidget, QStringList(QString("1;2;3;4;5").split(QLatin1Char(';'))));
treeWidget.setTreePosition(2);
treeWidget.header()->hideSection(0); // make sure we skip hidden section(s)
treeWidget.header()->swapSections(1, 2); // make sure that we look for first visual index (and not first logical)

View File

@ -2007,7 +2007,7 @@ void tst_QTreeWidget::columnCount()
void tst_QTreeWidget::setHeaderLabels()
{
QStringList list = QString("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z").split(",");
QStringList list = QString("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z").split(QLatin1Char(','));
testWidget->setHeaderLabels(list);
QCOMPARE(testWidget->header()->count(), list.count());
}

View File

@ -502,7 +502,7 @@ static QString cstrings2QString( char **args )
while ( args[i] ) {
string += args[i];
if ( args[i+1] )
string += " ";
string += QLatin1Char(' ');
++i;
}
return string;
@ -1060,16 +1060,16 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2()
#ifdef Q_OS_UNIX
QByteArray validPath = QDir("/tmp").canonicalPath().toLatin1();
QByteArray nonExistentPath = "/nonexistent";
QByteArray pluginPath = validPath + ":" + nonExistentPath;
QByteArray pluginPath = validPath + ':' + nonExistentPath;
#elif defined(Q_OS_WIN)
# ifdef Q_OS_WINCE
QByteArray validPath = "/Temp";
QByteArray nonExistentPath = "/nonexistent";
QByteArray pluginPath = validPath + ";" + nonExistentPath;
QByteArray pluginPath = validPath + ';' + nonExistentPath;
# else
QByteArray validPath = "C:\\windows";
QByteArray nonExistentPath = "Z:\\nonexistent";
QByteArray pluginPath = validPath + ";" + nonExistentPath;
QByteArray pluginPath = validPath + ';' + nonExistentPath;
# endif
#endif

View File

@ -195,7 +195,7 @@ void tst_QLayout::smartMaxSize()
int width = sz.width();
int expectedWidth = expectedWidths[expectedIndex];
if (width != expectedWidth) {
qDebug() << "error at index" << expectedIndex << ":" << sizePolicy.horizontalPolicy() << align << minSize << sizeHint << maxSize << width;
qDebug() << "error at index" << expectedIndex << ':' << sizePolicy.horizontalPolicy() << align << minSize << sizeHint << maxSize << width;
++regressionCount;
}
++expectedIndex;

View File

@ -61,7 +61,7 @@ public:
protected:
QStringList splitPath(const QString &path) const {
return csv ? path.split(",") : QCompleter::splitPath(path);
return csv ? path.split(QLatin1Char(',')) : QCompleter::splitPath(path);
}
private:

View File

@ -259,7 +259,7 @@ bool BaselineHandler::establishConnection()
logMsg += key + QLS(": '") + clientInfo.value(key) + QLS("', ");
}
qDebug() << runId << logtime() << "Connection established with" << clientInfo.value(PI_HostName)
<< "[" << qPrintable(clientInfo.value(PI_HostAddress)) << "]" << logMsg
<< '[' << qPrintable(clientInfo.value(PI_HostAddress)) << ']' << logMsg
<< "Overrides:" << clientInfo.overrides() << "AdHoc-Run:" << clientInfo.isAdHocRun();
// ### Hardcoded backwards compatibility: add project field for certain existing clients that lack it

View File

@ -309,7 +309,7 @@ void Report::writeFunctionResults(const ImageItemList &list)
out << "<span style=\"color:green\"><small>No mismatch reported</small></span>";
break;
default:
out << "?";
out << '?';
break;
}
out << "</td>\n";
@ -401,14 +401,14 @@ QString Report::writeResultsXmlFiles()
if (!cwd.exists(dir))
cwd.mkpath(dir);
foreach (const QString &func, itemLists.keys()) {
QFile f(dir + "/" + func + "-results.xml");
QFile f(dir + QLatin1Char('/') + func + "-results.xml");
if (!f.open(QIODevice::WriteOnly))
continue;
QXmlStreamWriter s(&f);
s.setAutoFormatting(true);
s.writeStartDocument();
foreach (QString key, plat.keys()) {
QString cmt = " " + key + "=\"" + plat.value(key) +"\" ";
QString cmt = QLatin1Char(' ') + key + "=\"" + plat.value(key) +"\" ";
s.writeComment(cmt.replace("--", "[-]"));
}
s.writeStartElement("testsuite");

View File

@ -56,11 +56,11 @@ void tst_QTextCodec::codecForName() const
QBENCHMARK {
foreach(const QByteArray& c, codecs) {
QVERIFY(QTextCodec::codecForName(c));
QVERIFY(QTextCodec::codecForName(c + "-"));
QVERIFY(QTextCodec::codecForName(c + '-'));
}
foreach(const QByteArray& c, codecs) {
QVERIFY(QTextCodec::codecForName(c + "+"));
QVERIFY(QTextCodec::codecForName(c + "*"));
QVERIFY(QTextCodec::codecForName(c + '+'));
QVERIFY(QTextCodec::codecForName(c + '*'));
}
}
}

View File

@ -602,7 +602,7 @@ void tst_qfile::createSmallFiles()
for (int i = 0; i < 1000; ++i)
#endif
{
QFile f(tmpDirName+"/"+QString::number(i));
QFile f(tmpDirName + QLatin1Char('/') + QString::number(i));
f.open(QIODevice::WriteOnly);
f.seek(511);
f.putChar('\n');
@ -641,7 +641,7 @@ void tst_qfile::readSmallFiles()
case(QFileBenchmark): {
QList<QFile*> fileList;
Q_FOREACH(QString file, files) {
QFile *f = new QFile(tmpDirName+ "/" + file);
QFile *f = new QFile(tmpDirName + QLatin1Char('/') + file);
f->open(QIODevice::ReadOnly|textMode|bufferedMode);
fileList.append(f);
}
@ -664,7 +664,7 @@ void tst_qfile::readSmallFiles()
case(QFSFileEngineBenchmark): {
QList<QFSFileEngine*> fileList;
Q_FOREACH(QString file, files) {
QFSFileEngine *fse = new QFSFileEngine(tmpDirName+ "/" + file);
QFSFileEngine *fse = new QFSFileEngine(tmpDirName + QLatin1Char('/') + file);
fse->open(QIODevice::ReadOnly|textMode|bufferedMode);
fileList.append(fse);
}
@ -685,7 +685,7 @@ void tst_qfile::readSmallFiles()
case(PosixBenchmark): {
QList<FILE*> fileList;
Q_FOREACH(QString file, files) {
fileList.append(::fopen(QFile::encodeName(tmpDirName+ "/" + file).constData(), "rb"));
fileList.append(::fopen(QFile::encodeName(tmpDirName + QLatin1Char('/') + file).constData(), "rb"));
}
QBENCHMARK {

View File

@ -100,7 +100,7 @@ bool readSettingsFromCommandLine(int argc, char *argv[],
return false;
}
else {
QStringList res = QString(argv[i+1]).split("x");
QStringList res = QString(argv[i+1]).split(QLatin1Char('x'));
if (res.count() != 2) {
printf("-resolution parameter UI resolution should be set in format WxH where width and height are positive values\n");
usage(argv[0]);

View File

@ -81,7 +81,8 @@ QString DummyDataGenerator::randomPhoneNumber(QString indexNumber)
QString beginNumber = QString::number(555-index*2);
QString endNumber = QString("0").repeated(4-indexNumber.length()) + indexNumber;
return countryCode +" " + areaCode +" " + beginNumber +" " + endNumber;
return countryCode + QLatin1Char(' ') + areaCode +QLatin1Char(' ') + beginNumber
+ QLatin1Char(' ') + endNumber;
}
QString DummyDataGenerator::randomFirstName()

View File

@ -130,7 +130,7 @@ void BenchQHeaderView::init()
for (int i = 0; i < m_model->rowCount(); ++i) {
m_model->setData(m_model->index(i, 0), QVariant(i));
s.setNum(i);
s += ".";
s += QLatin1Char('.');
s += 'a' + (i % 25);
m_model->setData(m_model->index(i, 1), QVariant(s));
}

View File

@ -285,7 +285,7 @@ void tst_QSqlQuery::benchmarkSelectPrepared()
int expectedSum = 0;
QString fillQuery = "INSERT INTO " + tableName + " VALUES (0)";
for (int i = 1; i < NUM_ROWS; ++i) {
fillQuery += ", (" + QString::number(i) + ")";
fillQuery += ", (" + QString::number(i) + QLatin1Char(')');
expectedSum += i;
}
QVERIFY_SQL(q, exec(fillQuery));

View File

@ -147,7 +147,7 @@ void BearerEx::on_createSessionButton_clicked()
QNetworkConfiguration networkConfiguration = qvariant_cast<QNetworkConfiguration>(item->data(Qt::UserRole));
int newTabIndex = mainTabWidget->count();
SessionTab* newTab = new SessionTab(&networkConfiguration,&m_NetworkConfigurationManager,eventListWidget,newTabIndex-1);
QString label = QString("S")+QString::number(newTabIndex-1);
QString label = QLatin1Char('S') + QString::number(newTabIndex-1);
mainTabWidget->insertTab(newTabIndex,newTab,label);
mainTabWidget->setCurrentIndex(newTabIndex);
}
@ -271,9 +271,11 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration,
snapLabel->hide();
snapLineEdit->hide();
alrButton->hide();
iapLineEdit->setText(apNetworkConfiguration->name()+" ("+apNetworkConfiguration->identifier()+")");
iapLineEdit->setText(apNetworkConfiguration->name()+ " (" + apNetworkConfiguration->identifier()
+ QLatin1Char(')'));
} else if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) {
snapLineEdit->setText(apNetworkConfiguration->name()+" ("+apNetworkConfiguration->identifier()+")");
snapLineEdit->setText(apNetworkConfiguration->name()+ " (" + apNetworkConfiguration->identifier()
+ QLatin1Char(')'));
}
bearerLineEdit->setText(apNetworkConfiguration->bearerTypeName());
sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+
@ -380,7 +382,7 @@ void SessionTab::newConfigurationActivated()
msgBox.setDefaultButton(QMessageBox::Yes);
if (msgBox.exec() == QMessageBox::Yes) {
m_NetworkSession->accept();
iapLineEdit->setText(m_config.name()+" ("+m_config.identifier()+")");
iapLineEdit->setText(m_config.name() + " (" + m_config.identifier() + QLatin1Char(')'));
} else {
m_NetworkSession->reject();
}
@ -391,7 +393,7 @@ void SessionTab::preferredConfigurationChanged(const QNetworkConfiguration& conf
m_config = config;
QMessageBox msgBox;
msgBox.setText("Roaming to new configuration.");
msgBox.setInformativeText("Do you want to migrate to "+config.name()+"?");
msgBox.setInformativeText("Do you want to migrate to " + config.name() + QLatin1Char('?'));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
if (msgBox.exec() == QMessageBox::Yes) {
@ -407,7 +409,7 @@ void SessionTab::opened()
QFont font = listItem->font();
font.setBold(true);
listItem->setFont(font);
listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Opened"));
listItem->setText(QLatin1Char('S') + QString::number(m_index) + QLatin1String(" - Opened"));
m_eventListWidget->addItem(listItem);
QVariant identifier = m_NetworkSession->sessionProperty("ActiveConfiguration");
@ -415,7 +417,7 @@ void SessionTab::opened()
QString configId = identifier.toString();
QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
if (config.isValid()) {
iapLineEdit->setText(config.name()+" ("+config.identifier()+")");
iapLineEdit->setText(config.name() + " (" + config.identifier() + QLatin1Char(')'));
}
}
newState(m_NetworkSession->state()); // Update the "(open)"
@ -438,7 +440,7 @@ void SessionTab::closed()
QFont font = listItem->font();
font.setBold(true);
listItem->setFont(font);
listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Closed"));
listItem->setText(QLatin1Char('S') + QString::number(m_index) + QLatin1String(" - Closed"));
m_eventListWidget->addItem(listItem);
}
@ -489,7 +491,7 @@ void SessionTab::stateChanged(QNetworkSession::State state)
newState(state);
QListWidgetItem* listItem = new QListWidgetItem();
listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+stateString(state));
listItem->setText(QLatin1Char('S') + QString::number(m_index) + QLatin1String(" - ") + stateString(state));
m_eventListWidget->addItem(listItem);
}
@ -500,7 +502,7 @@ void SessionTab::newState(QNetworkSession::State state)
QString configId = identifier.toString();
QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
if (config.isValid()) {
iapLineEdit->setText(config.name()+" ("+config.identifier()+")");
iapLineEdit->setText(config.name() + " (" + config.identifier() + QLatin1Char(')'));
bearerLineEdit->setText(config.bearerTypeName());
}
} else {
@ -539,7 +541,7 @@ void SessionTab::error(QNetworkSession::SessionError error)
errorString = "InvalidConfigurationError";
break;
}
listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+errorString);
listItem->setText(QLatin1Char('S') + QString::number(m_index) + QString(" - ") + errorString);
m_eventListWidget->addItem(listItem);
msgBox.setText(errorString);

View File

@ -175,7 +175,7 @@ void MainWindow::setDirectory(const QString &path)
QDir dir(path);
QStringList files = dir.entryList(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot);
foreach(const QString &file, files) {
QImageReader img(path + QLatin1String("/")+file);
QImageReader img(path + QLatin1Char('/') +file);
QImage image = img.read();
if (!image.isNull()) {
{

View File

@ -166,7 +166,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event)
QMimeData *mimeData = new QMimeData;
mimeData->setText(child->text());
mimeData->setData("application/x-hotspot",
QByteArray::number(hotSpot.x()) + " " + QByteArray::number(hotSpot.y()));
QByteArray::number(hotSpot.x()) + ' ' + QByteArray::number(hotSpot.y()));
QPixmap pixmap(child->size());
child->render(&pixmap);

View File

@ -139,7 +139,7 @@ private slots:
// update label, add ".0" if needed.
QString number = QString::number(scalefactorF);
if (!number.contains("."))
if (!number.contains(QLatin1Char('.')))
number.append(".0");
m_label->setText(number);
}
@ -203,8 +203,8 @@ DemoController::DemoController(DemoContainerList *demos, QCommandLineParser *par
foreach (QScreen *screen, screens) {
// create scale control line
QSize screenSize = screen->geometry().size();
QString screenId = screen->name() + " " + QString::number(screenSize.width())
+ " " + QString::number(screenSize.height());
QString screenId = screen->name() + QLatin1Char(' ') + QString::number(screenSize.width())
+ QLatin1Char(' ') + QString::number(screenSize.height());
LabelSlider *slider = new LabelSlider(this, screenId, layout, layoutRow++);
slider->setValue(getScreenFactorWithoutPixelDensity(screen) * 10);

View File

@ -602,7 +602,7 @@ int main(int argc, char **argv)
pcmd.setType(type);
pcmd.setCheckersBackground(checkers_background);
pcmd.setContents(content);
QString file = QString(files.at(j)).replace(".", "_") + ".ps";
QString file = QString(files.at(j)).replace(QLatin1Char('.'), QLatin1Char('_')) + ".ps";
QPrinter p(highres ? QPrinter::HighResolution : QPrinter::ScreenResolution);
if (printdlg) {

View File

@ -141,7 +141,7 @@ void MiniHttpServerConnection::handlePendingRequest()
}
QUrl uri = QUrl::fromEncoded(request.mid(4, eol - int(strlen(http11)) - 4));
source.setFileName(":" + uri.path());
source.setFileName(QLatin1Char(':') + uri.path());
// connection-close?
request = request.toLower();

View File

@ -159,7 +159,7 @@ int main(int argc, char *argv[])
headersFile=str.mid(10);
else if (str == "--serial")
dl.setQueueMode(DownloadManager::Serial);
else if (str.startsWith("-"))
else if (str.startsWith(QLatin1Char('-')))
qDebug() << "unsupported option" << str;
else {
QUrl url(QUrl::fromUserInput(str));

View File

@ -42,9 +42,9 @@ TransferItem::TransferItem(const QNetworkRequest &r, const QString &u, const QSt
void TransferItem::progress(qint64 sent, qint64 total)
{
if (total > 0)
qDebug() << (sent*100/total) << "%";
qDebug() << (sent*100/total) << '%';
else
qDebug() << sent << "B";
qDebug() << sent << 'B';
}
void TransferItem::start()

View File

@ -87,7 +87,7 @@ void PropertyField::propertyChanged()
m_lastChangeTime = QTime::currentTime().addSecs(-5);
}
qDebug() << " " << QString::fromUtf8(m_prop.name()) << ":" << val;
qDebug() << " " << QString::fromUtf8(m_prop.name()) << ':' << val;
// If the value has recently changed, show the change
if (text != m_lastText || m_lastChangeTime.elapsed() < 1000) {
setText(m_lastTextShowing + " -> " + text);

View File

@ -201,7 +201,7 @@ QString TabletWidget::buttonsToString(Qt::MouseButtons bs)
if (bs.testFlag(b))
ret << buttonToString(b);
}
return ret.join("|");
return ret.join(QLatin1Char('|'));
}
void TabletWidget::tabletEvent(QTabletEvent *event)

View File

@ -63,7 +63,7 @@ protected:
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
label->setOpenExternalLinks(true);
QString link("<a href=" + path + ">" + path + "</a>");
QString link("<a href=" + path + QLatin1Char('>') + path + "</a>");
label->setText(link);
return label;