Prefix QTextStream operators with Qt:: in tests

Change-Id: I852f016fcb619a9e634deee6efb1fe7930d974c8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Lars Knoll 2019-05-02 09:24:11 +02:00
parent f27f89f335
commit e3b55616e2
13 changed files with 49 additions and 49 deletions

View File

@ -309,7 +309,7 @@ void tst_QDebug::stateSaver() const
QDebug d = qDebug();
{
QDebugStateSaver saver(d);
d.nospace() << hex << right << qSetFieldWidth(3) << qSetPadChar('0') << 42;
d.nospace() << Qt::hex << Qt::right << qSetFieldWidth(3) << qSetPadChar('0') << 42;
}
d << 42;
}
@ -327,7 +327,7 @@ void tst_QDebug::stateSaver() const
{
QDebug d = qDebug();
d.noquote().nospace() << QStringLiteral("Hello") << hex << 42;
d.noquote().nospace() << QStringLiteral("Hello") << Qt::hex << 42;
{
QDebugStateSaver saver(d);
d.resetFormat();
@ -660,7 +660,7 @@ void tst_QDebug::textStreamModifiers() const
QString file, function;
int line = 0;
MessageHandlerSetter mhs(myMessageHandler);
{ qDebug() << hex << short(0xf) << int(0xf) << unsigned(0xf) << long(0xf) << qint64(0xf) << quint64(0xf); }
{ qDebug() << Qt::hex << short(0xf) << int(0xf) << unsigned(0xf) << long(0xf) << qint64(0xf) << quint64(0xf); }
#ifndef QT_NO_MESSAGELOGCONTEXT
file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO;
#endif
@ -678,7 +678,7 @@ void tst_QDebug::resetFormat() const
MessageHandlerSetter mhs(myMessageHandler);
{
QDebug d = qDebug();
d.nospace().noquote() << hex << int(0xf);
d.nospace().noquote() << Qt::hex << int(0xf);
d.resetFormat() << int(0xf) << QStringLiteral("foo");
}
#ifndef QT_NO_MESSAGELOGCONTEXT

View File

@ -2099,7 +2099,7 @@ void tst_QFile::i18nFileName()
QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
ts.setCodec("UTF-8");
ts << fileName << endl;
ts << fileName << Qt::endl;
}
{
QFile file(fileName);
@ -2149,7 +2149,7 @@ void tst_QFile::longFileName()
QFile file(fileName);
QVERIFY2(file.open(QFile::WriteOnly | QFile::Text), msgOpenFailed(file).constData());
QTextStream ts(&file);
ts << fileName << endl;
ts << fileName << Qt::endl;
}
{
QFile file(fileName);

View File

@ -1182,7 +1182,7 @@ void tst_QFileInfo::fileTimes()
QTest::qSleep(sleepTime);
beforeWrite = QDateTime::currentDateTime().addMSecs(-fsClockSkew);
QTextStream ts(&file);
ts << fileName << endl;
ts << fileName << Qt::endl;
}
{
QFileInfo fileInfo(fileName);

View File

@ -104,7 +104,7 @@ public:
for (int a = 0; a < _configitemEntryOrder.count(); a++) {
out << _configitemEntryOrder[a]
<< " = "
<< _values.value(_configitemEntryOrder[a]) << endl;
<< _values.value(_configitemEntryOrder[a]) << Qt::endl;
}
out.flush();
return ret.toLatin1();

View File

@ -41,7 +41,7 @@ int main(int argc, char **argv)
do {
line = qin.readLine();
if (!line.isNull())
qerr << line << flush;
qerr << line << Qt::flush;
} while (!line.isNull());
return 0;
}

View File

@ -245,7 +245,7 @@ private:
void runOnExit()
{
QByteArray buffer;
QTextStream(&buffer) << "This will try to use QTextCodec::codecForLocale" << endl;
QTextStream(&buffer) << "This will try to use QTextCodec::codecForLocale" << Qt::endl;
}
Q_DESTRUCTOR_FUNCTION(runOnExit)
@ -1506,9 +1506,9 @@ void tst_QTextStream::readStdin()
stdinProcess.setReadChannel(QProcess::StandardError);
QTextStream stream(&stdinProcess);
stream << "1" << endl;
stream << "2" << endl;
stream << "3" << endl;
stream << "1" << Qt::endl;
stream << "2" << Qt::endl;
stream << "3" << Qt::endl;
stdinProcess.closeWriteChannel();
@ -1534,7 +1534,7 @@ void tst_QTextStream::readAllFromStdin()
QTextStream stream(&stdinProcess);
stream.setCodec("ISO-8859-1");
stream << "hello world" << flush;
stream << "hello world" << Qt::flush;
stdinProcess.closeWriteChannel();
@ -1824,7 +1824,7 @@ void tst_QTextStream::utf8IncompleteAtBufferBoundary()
out.setFieldWidth(3);
for (int i = 0; i < 1000; ++i) {
out << i << lineContents << endl;
out << i << lineContents << Qt::endl;
}
}
data.close();
@ -2726,7 +2726,7 @@ void tst_QTextStream::generateBOM()
QTextStream stream(&file);
stream.setCodec(QTextCodec::codecForName("UTF-16LE"));
stream << "Hello" << endl;
stream << "Hello" << Qt::endl;
file.close();
QVERIFY(file.open(QFile::ReadOnly));
@ -2740,7 +2740,7 @@ void tst_QTextStream::generateBOM()
QTextStream stream(&file);
stream.setCodec(QTextCodec::codecForName("UTF-16LE"));
stream << bom << "Hello" << endl;
stream << Qt::bom << "Hello" << Qt::endl;
file.close();
QVERIFY(file.open(QFile::ReadOnly));

View File

@ -115,7 +115,7 @@ static QByteArray makeCanonical(const QString &filename,
writeDtd << "<!DOCTYPE ";
writeDtd << docType;
writeDtd << " [";
writeDtd << endl;
writeDtd << Qt::endl;
for (const QXmlStreamNotationDeclaration &notation : sorted_by_name(notationDeclarations)) {
writeDtd << "<!NOTATION ";
writeDtd << notation.name().toString();
@ -134,11 +134,11 @@ static QByteArray makeCanonical(const QString &filename,
}
}
writeDtd << '>';
writeDtd << endl;
writeDtd << Qt::endl;
}
writeDtd << "]>";
writeDtd << endl;
writeDtd << Qt::endl;
writer.writeDTD(dtd);
}
} else if (reader.isStartElement()) {
@ -740,7 +740,7 @@ QByteArray tst_QXmlStream::readFile(const QString &filename)
const auto attributes = reader.attributes();
if (attributes.size()) {
for (const QXmlStreamAttribute &attribute : attributes) {
writer << endl << " Attribute(";
writer << Qt::endl << " Attribute(";
if (!attribute.name().isEmpty())
writer << " name=\"" << attribute.name().toString() << '"';
if (!attribute.namespaceUri().isEmpty())
@ -751,37 +751,37 @@ QByteArray tst_QXmlStream::readFile(const QString &filename)
writer << " prefix=\"" << attribute.prefix().toString() << '"';
if (!attribute.value().isEmpty())
writer << " value=\"" << attribute.value().toString() << '"';
writer << " )" << endl;
writer << " )" << Qt::endl;
}
}
const auto namespaceDeclarations = reader.namespaceDeclarations();
if (namespaceDeclarations.size()) {
for (const QXmlStreamNamespaceDeclaration &namespaceDeclaration : namespaceDeclarations) {
writer << endl << " NamespaceDeclaration(";
writer << Qt::endl << " NamespaceDeclaration(";
if (!namespaceDeclaration.prefix().isEmpty())
writer << " prefix=\"" << namespaceDeclaration.prefix().toString() << '"';
if (!namespaceDeclaration.namespaceUri().isEmpty())
writer << " namespaceUri=\"" << namespaceDeclaration.namespaceUri().toString() << '"';
writer << " )" << endl;
writer << " )" << Qt::endl;
}
}
const auto notationDeclarations = reader.notationDeclarations();
if (notationDeclarations.size()) {
for (const QXmlStreamNotationDeclaration &notationDeclaration : notationDeclarations) {
writer << endl << " NotationDeclaration(";
writer << Qt::endl << " NotationDeclaration(";
if (!notationDeclaration.name().isEmpty())
writer << " name=\"" << notationDeclaration.name().toString() << '"';
if (!notationDeclaration.systemId().isEmpty())
writer << " systemId=\"" << notationDeclaration.systemId().toString() << '"';
if (!notationDeclaration.publicId().isEmpty())
writer << " publicId=\"" << notationDeclaration.publicId().toString() << '"';
writer << " )" << endl;
writer << " )" << Qt::endl;
}
}
const auto entityDeclarations = reader.entityDeclarations();
if (entityDeclarations.size()) {
for (const QXmlStreamEntityDeclaration &entityDeclaration : entityDeclarations) {
writer << endl << " EntityDeclaration(";
writer << Qt::endl << " EntityDeclaration(";
if (!entityDeclaration.name().isEmpty())
writer << " name=\"" << entityDeclaration.name().toString() << '"';
if (!entityDeclaration.notationName().isEmpty())
@ -792,13 +792,13 @@ QByteArray tst_QXmlStream::readFile(const QString &filename)
writer << " publicId=\"" << entityDeclaration.publicId().toString() << '"';
if (!entityDeclaration.value().isEmpty())
writer << " value=\"" << entityDeclaration.value().toString() << '"';
writer << " )" << endl;
writer << " )" << Qt::endl;
}
}
writer << " )" << endl;
writer << " )" << Qt::endl;
}
if (reader.hasError())
writer << "ERROR: " << reader.errorString() << endl;
writer << "ERROR: " << reader.errorString() << Qt::endl;
return outarray;
}
@ -1169,7 +1169,7 @@ int main(int argc, char *argv[])
bool error = false;
QByteArray canonical = makeCanonical(argv[2], "doc", error);
QTextStream myStdOut(stdout);
myStdOut << canonical << endl;
myStdOut << canonical << Qt::endl;
exit(0);
}

View File

@ -208,7 +208,7 @@ void printHeader(QStringList &headers)
for (int h = 0; h < headers.count(); ++h) {
cout << setw(20) << setiosflags(ios_base::left) << headers.at(h).toLatin1().constData();
}
cout << endl;
cout << Qt::endl;
}
template <typename ContainerType>
@ -220,7 +220,7 @@ void print(ContainerType testContainer)
cout << value << " ";
}
cout << endl;
cout << Qt::endl;
}
template <typename Algorithm, typename DataType>
@ -252,7 +252,7 @@ void testAlgorithm(Algorithm algorithm, QStringList &dataSetTypes)
lessThan << setiosflags(ios_base::left) << setw(10) << result.lessThanRefCount / result.numSorts;
cout << numSorts.str() << lessThan.str();
}
cout << endl;
cout << Qt::endl;
}
}
#endif
@ -765,21 +765,21 @@ public:
#if Q_TEST_PERFORMANCE
void tst_QAlgorithms::performance()
{
cout << endl << "Quick sort" << endl;
cout << Qt::endl << "Quick sort" << Qt::endl;
testAlgorithm<QuickSortHelper<TestInt>, TestInt>(QuickSortHelper<TestInt>(), dataSetTypes);
cout << endl << "stable sort" << endl;
cout << Qt::endl << "stable sort" << Qt::endl;
testAlgorithm<StableSortHelper<TestInt>, TestInt>(StableSortHelper<TestInt>(), dataSetTypes);
cout << endl << "std::sort" << endl;
cout << Qt::endl << "std::sort" << Qt::endl;
testAlgorithm<StlSortHelper<TestInt>, TestInt>(StlSortHelper<TestInt>(), dataSetTypes);
cout << endl << "std::stable_sort" << endl;
cout << Qt::endl << "std::stable_sort" << Qt::endl;
testAlgorithm<StlStableSortHelper<TestInt>, TestInt>(StlStableSortHelper<TestInt>(), dataSetTypes);
/*
cout << endl << "Sorting lists of ints" << endl;
cout << endl << "Quick sort" << endl;
cout << Qt::endl << "Sorting lists of ints" << Qt::endl;
cout << Qt::endl << "Quick sort" << Qt::endl;
testAlgorithm<QuickSortHelper<int>, int>(QuickSortHelper<int>(), dataSetTypes);
cout << endl << "std::sort" << endl;
cout << Qt::endl << "std::sort" << Qt::endl;
testAlgorithm<StlSortHelper<int>, int>(StlSortHelper<int>(), dataSetTypes);
cout << endl << "std::stable_sort" << endl;
cout << Qt::endl << "std::stable_sort" << Qt::endl;
testAlgorithm<StlStableSortHelper<int>, int>(StlStableSortHelper<int>(), dataSetTypes);
*/
}

View File

@ -121,7 +121,7 @@ static QByteArray modifiersTestRowName(const QString &keySequence)
if (uc > 32 && uc < 128)
str << '"' << c << '"';
else
str << "U+" << hex << uc << dec;
str << "U+" << Qt::hex << uc << Qt::dec;
if (i < size - 1)
str << ',';
}

View File

@ -681,7 +681,7 @@ static bool checkPixels(const QImage &image,
if (pixel != expectedRgb1 && pixel != expectedRgb2) {
QString message;
QDebug(&message) << "Color mismatch in image" << image
<< "at" << x << ',' << y << ':' << showbase << hex << pixel
<< "at" << x << ',' << y << ':' << Qt::showbase << Qt::hex << pixel
<< "(expected: " << expectedRgb1 << ',' << expectedRgb2 << ')';
*errorMessage = message.toLocal8Bit();
return false;

View File

@ -552,7 +552,7 @@ void tst_QLocalSocket::sendData()
QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState);
QTextStream out(serverSocket);
QTextStream in(&socket);
out << testLine << endl;
out << testLine << Qt::endl;
bool wrote = serverSocket->waitForBytesWritten(3000);
if (!socket.canReadLine()) {
@ -877,7 +877,7 @@ public:
QLocalSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
QTextStream out(serverSocket);
out << testLine << endl;
out << testLine << Qt::endl;
QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState);
QVERIFY2(serverSocket->waitForBytesWritten(), serverSocket->errorString().toLatin1().constData());
QCOMPARE(serverSocket->errorString(), QString("Unknown error"));

View File

@ -8386,7 +8386,7 @@ void tst_QGraphicsItem::focusProxy()
QString err;
QTextStream stream(&err);
stream << "QGraphicsItem::setFocusProxy: "
<< (void*)item << " is already in the focus proxy chain" << flush;
<< (void*)item << " is already in the focus proxy chain" << Qt::flush;
QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
item2->setFocusProxy(item); // fails
QCOMPARE(item->focusProxy(), (QGraphicsItem *)item2);

View File

@ -72,7 +72,7 @@ int main(int argc, const char *argv[])
QFile in_file(file_name);
if (!in_file.open(QIODevice::ReadOnly)) {
qerr << "Could not open " << file_name << ": " << strerror(errno) << endl;
qerr << "Could not open " << file_name << ": " << strerror(errno) << Qt::endl;
return 1;
}
@ -87,7 +87,7 @@ int main(int argc, const char *argv[])
} else {
_out_file.setFileName(out_file_name);
if (!_out_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
qerr << "Could not open " << out_file_name << ": " << strerror(errno) << endl;
qerr << "Could not open " << out_file_name << ": " << strerror(errno) << Qt::endl;
return 1;
}
_out_stream.setDevice(&_out_file);