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(); QDebug d = qDebug();
{ {
QDebugStateSaver saver(d); 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; d << 42;
} }
@ -327,7 +327,7 @@ void tst_QDebug::stateSaver() const
{ {
QDebug d = qDebug(); QDebug d = qDebug();
d.noquote().nospace() << QStringLiteral("Hello") << hex << 42; d.noquote().nospace() << QStringLiteral("Hello") << Qt::hex << 42;
{ {
QDebugStateSaver saver(d); QDebugStateSaver saver(d);
d.resetFormat(); d.resetFormat();
@ -660,7 +660,7 @@ void tst_QDebug::textStreamModifiers() const
QString file, function; QString file, function;
int line = 0; int line = 0;
MessageHandlerSetter mhs(myMessageHandler); 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 #ifndef QT_NO_MESSAGELOGCONTEXT
file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO;
#endif #endif
@ -678,7 +678,7 @@ void tst_QDebug::resetFormat() const
MessageHandlerSetter mhs(myMessageHandler); MessageHandlerSetter mhs(myMessageHandler);
{ {
QDebug d = qDebug(); QDebug d = qDebug();
d.nospace().noquote() << hex << int(0xf); d.nospace().noquote() << Qt::hex << int(0xf);
d.resetFormat() << int(0xf) << QStringLiteral("foo"); d.resetFormat() << int(0xf) << QStringLiteral("foo");
} }
#ifndef QT_NO_MESSAGELOGCONTEXT #ifndef QT_NO_MESSAGELOGCONTEXT

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8386,7 +8386,7 @@ void tst_QGraphicsItem::focusProxy()
QString err; QString err;
QTextStream stream(&err); QTextStream stream(&err);
stream << "QGraphicsItem::setFocusProxy: " 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()); QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
item2->setFocusProxy(item); // fails item2->setFocusProxy(item); // fails
QCOMPARE(item->focusProxy(), (QGraphicsItem *)item2); QCOMPARE(item->focusProxy(), (QGraphicsItem *)item2);

View File

@ -72,7 +72,7 @@ int main(int argc, const char *argv[])
QFile in_file(file_name); QFile in_file(file_name);
if (!in_file.open(QIODevice::ReadOnly)) { 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; return 1;
} }
@ -87,7 +87,7 @@ int main(int argc, const char *argv[])
} else { } else {
_out_file.setFileName(out_file_name); _out_file.setFileName(out_file_name);
if (!_out_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { 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; return 1;
} }
_out_stream.setDevice(&_out_file); _out_stream.setDevice(&_out_file);