summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/serialization
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-04-16 16:32:08 +0200
commit6630937e63ae5797487b86743a7733c8ae5cc42c (patch)
tree3d53dacf6430f9099e1fb20835881205de674961 /tests/auto/corelib/serialization
parent37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff)
parentc7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff)
Merge commit 'dev' into 'wip/cmake-merge'
Diffstat (limited to 'tests/auto/corelib/serialization')
-rw-r--r--tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp4
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp61
-rw-r--r--tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp127
-rw-r--r--tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro4
-rw-r--r--tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp68
-rw-r--r--tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro3
-rw-r--r--tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro3
-rw-r--r--tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro3
-rw-r--r--tests/auto/corelib/serialization/qtextstream/test/test.pro2
-rw-r--r--tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp102
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp2
-rw-r--r--tests/auto/corelib/serialization/serialization.pro1
12 files changed, 303 insertions, 77 deletions
diff --git a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
index 24d9c7409e..3dd4b5114c 100644
--- a/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
+++ b/tests/auto/corelib/serialization/qcborstreamreader/tst_qcborstreamreader.cpp
@@ -269,7 +269,7 @@ void tst_QCborStreamReader::integers()
quint64 absolute = (isNegative ? expectedRaw + 1 : expectedRaw);
QBuffer buffer(&data);
- QCborStreamReader reader(data);
+ QCborStreamReader reader(useDevice ? QByteArray() : data);
if (useDevice) {
buffer.open(QIODevice::ReadOnly);
reader.setDevice(&buffer);
@@ -605,7 +605,7 @@ void tst_QCborStreamReader::fixed()
removeIndicators(expected);
QBuffer buffer(&data);
- QCborStreamReader reader(data);
+ QCborStreamReader reader(useDevice ? QByteArray() : data);
if (useDevice) {
buffer.open(QIODevice::ReadOnly);
reader.setDevice(&buffer);
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index 1b818ad152..f69ce4120d 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -334,7 +334,7 @@ void tst_QCborValue::copyCompare()
QCOMPARE(v, other);
QVERIFY(!(v != other));
QVERIFY(!(v < other));
-#if QT_HAS_INCLUDE(<compare>)
+#if 0 && QT_HAS_INCLUDE(<compare>)
QVERIFY(v <= other);
QVERIFY(v >= other);
QVERIFY(!(v > other));
@@ -384,11 +384,17 @@ void tst_QCborValue::arrayDefaultInitialization()
QVERIFY(v.isArray());
QVERIFY(!v.isMap());
QVERIFY(!v.isTag());
- QVERIFY(v[0].isUndefined());
QCborArray a2 = v.toArray();
QVERIFY(a2.isEmpty());
QCOMPARE(a2, a);
+ auto front = v[0];
+ QVERIFY(front.isUndefined());
+ front = 1;
+ QCOMPARE(v[0], 1);
+ QVERIFY(a2.isEmpty());
+ a2 = v.toArray();
+ QCOMPARE(a2.size(), 1);
}
void tst_QCborValue::mapDefaultInitialization()
@@ -425,7 +431,7 @@ void tst_QCborValue::mapDefaultInitialization()
QVERIFY(m == QCborMap{});
QVERIFY(QCborMap{} == m);
- QCborValue v(m);
+ const QCborValue v(m);
QVERIFY(v.isMap());
QVERIFY(!v.isArray());
QVERIFY(!v.isTag());
@@ -727,6 +733,31 @@ void tst_QCborValue::arrayMutation()
QCOMPARE(a.at(1), QCborValue(-1));
QCOMPARE(a2.at(1), QCborValue(nullptr));
QCOMPARE(++it, end);
+
+ // Array accessed via value:
+ QCborValue val(a);
+ val[2] = QCborArray{2, 3, 5, 7};
+ QCOMPARE(a.size(), 2); // Unchanged
+ QVERIFY(val.isArray());
+ QCOMPARE(val.toArray().size(), 3);
+ val[2][4] = 17;
+ QVERIFY(val.isArray());
+ QVERIFY(val[2].isArray());
+ QCOMPARE(val[2].toArray().size(), 5);
+ QCOMPARE(val[2][4], 17);
+ QCOMPARE(val.toArray().size(), 3);
+ val[3] = 42;
+ QVERIFY(val.isArray());
+ QCOMPARE(val.toArray().size(), 4);
+ QCOMPARE(val[3], 42);
+
+ // Coerce to map on string key:
+ const QLatin1String any("any");
+ val[any] = any;
+ QVERIFY(val.isMap());
+ QCOMPARE(val.toMap().size(), 5);
+ QVERIFY(val[2].isArray());
+ QCOMPARE(val[2].toArray().size(), 5);
}
void tst_QCborValue::mapMutation()
@@ -782,6 +813,30 @@ void tst_QCborValue::mapMutation()
QCOMPARE((m.end() - 1)->toInteger(), -1);
QVERIFY((m2.end() - 1)->isNull());
QCOMPARE(++it, end);
+
+ // Map accessed via value:
+ QCborValue val(m);
+ val[7] = QCborMap({{0, 2}, {1, 3}, {2, 5}});
+ QCOMPARE(m.size(), 2); // Unchanged
+ QVERIFY(val.isMap());
+ QCOMPARE(val.toMap().size(), 3);
+ val[7][3] = 11;
+ QVERIFY(val.isMap());
+ QVERIFY(val[7].isMap());
+ QCOMPARE(val[7].toMap().size(), 4);
+ val[14] = 42;
+ QVERIFY(val.isMap());
+ QCOMPARE(val.toMap().size(), 4);
+
+ const QLatin1String any("any");
+ const QString hello(QStringLiteral("Hello World"));
+ val[any][3][hello] = any;
+ QVERIFY(val.isMap());
+ QCOMPARE(val.toMap().size(), 5);
+ QVERIFY(val[any].isMap());
+ QCOMPARE(val[any].toMap().size(), 1);
+ QVERIFY(val[any][3].isMap());
+ QCOMPARE(val[any][3].toMap().size(), 1);
}
void tst_QCborValue::arrayPrepend()
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
index 085a638eb7..19cdd42a74 100644
--- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
@@ -181,6 +181,8 @@ private slots:
void streamRealDataTypes();
+ void enumTest();
+
void floatingPointPrecision();
void compatibility_Qt3();
@@ -2352,25 +2354,22 @@ void tst_QDataStream::setVersion()
}
}
-class SequentialBuffer : public QBuffer
+class SequentialBuffer : public QIODevice
{
public:
- SequentialBuffer(QByteArray *data) : QBuffer(data) { offset = 0; }
+ SequentialBuffer(QByteArray *data) : QIODevice() { buf.setBuffer(data); }
- bool isSequential() const { return true; }
- bool seek(qint64 pos) { offset = pos; return QBuffer::seek(pos); }
- qint64 pos() const { return qint64(offset); }
+ bool isSequential() const override { return true; }
+ bool open(OpenMode mode) override { return buf.open(mode) && QIODevice::open(mode | QIODevice::Unbuffered); }
+ void close() override { buf.close(); QIODevice::close(); }
+ qint64 bytesAvailable() const override { return QIODevice::bytesAvailable() + buf.bytesAvailable(); }
protected:
- qint64 readData(char *data, qint64 maxSize)
- {
- qint64 ret = QBuffer::readData(data, maxSize);
- offset += ret;
- return ret;
- }
+ qint64 readData(char *data, qint64 maxSize) override { return buf.read(data, maxSize); }
+ qint64 writeData(const char *data, qint64 maxSize) override { return buf.write(data, maxSize); }
private:
- int offset;
+ QBuffer buf;
};
void tst_QDataStream::skipRawData_data()
@@ -3412,6 +3411,90 @@ void tst_QDataStream::floatingPointNaN()
}
}
+void tst_QDataStream::enumTest()
+{
+ QByteArray ba;
+
+ enum class E1 : qint8
+ {
+ A,
+ B,
+ C
+ };
+ {
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << E1::A;
+ QCOMPARE(ba.size(), int(sizeof(E1)));
+ }
+ {
+ QDataStream stream(ba);
+ E1 e;
+ stream >> e;
+ QCOMPARE(e, E1::A);
+ }
+ ba.clear();
+
+ enum class E2 : qint16
+ {
+ A,
+ B,
+ C
+ };
+ {
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << E2::B;
+ QCOMPARE(ba.size(), int(sizeof(E2)));
+ }
+ {
+ QDataStream stream(ba);
+ E2 e;
+ stream >> e;
+ QCOMPARE(e, E2::B);
+ }
+ ba.clear();
+
+ enum class E4 : qint32
+ {
+ A,
+ B,
+ C
+ };
+ {
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << E4::C;
+ QCOMPARE(ba.size(), int(sizeof(E4)));
+ }
+ {
+ QDataStream stream(ba);
+ E4 e;
+ stream >> e;
+ QCOMPARE(e, E4::C);
+ }
+ ba.clear();
+
+
+ enum E
+ {
+ A,
+ B,
+ C,
+ D
+ };
+ {
+ QDataStream stream(&ba, QIODevice::WriteOnly);
+ stream << E::D;
+ QCOMPARE(ba.size(), 4);
+ }
+ {
+ QDataStream stream(ba);
+ E e;
+ stream >> e;
+ QCOMPARE(e, E::D);
+ }
+ ba.clear();
+
+}
+
void tst_QDataStream::floatingPointPrecision()
{
QByteArray ba;
@@ -3470,15 +3553,21 @@ void tst_QDataStream::transaction_data()
QTest::addColumn<bool>("bData");
QTest::addColumn<float>("fData");
QTest::addColumn<double>("dData");
+ QTest::addColumn<QImage>("imgData");
QTest::addColumn<QByteArray>("strData");
QTest::addColumn<QByteArray>("rawData");
+ QImage img1(open_xpm);
+ QImage img2;
+ QImage img3(50, 50, QImage::Format_ARGB32);
+ img3.fill(qRgba(12, 34, 56, 78));
+
QTest::newRow("1") << qint8(1) << qint16(2) << qint32(3) << qint64(4) << true << 5.0f
- << double(6.0) << QByteArray("Hello world!") << QByteArray("Qt rocks!");
+ << double(6.0) << img1 << QByteArray("Hello world!") << QByteArray("Qt rocks!");
QTest::newRow("2") << qint8(1 << 6) << qint16(1 << 14) << qint32(1 << 30) << qint64Data(3) << false << 123.0f
- << double(234.0) << stringData(5).toUtf8() << stringData(6).toUtf8();
+ << double(234.0) << img2 << stringData(5).toUtf8() << stringData(6).toUtf8();
QTest::newRow("3") << qint8(-1) << qint16(-2) << qint32(-3) << qint64(-4) << true << -123.0f
- << double(-234.0) << stringData(3).toUtf8() << stringData(4).toUtf8();
+ << double(-234.0) << img3 << stringData(3).toUtf8() << stringData(4).toUtf8();
}
void tst_QDataStream::transaction()
@@ -3492,6 +3581,7 @@ void tst_QDataStream::transaction()
QFETCH(bool, bData);
QFETCH(float, fData);
QFETCH(double, dData);
+ QFETCH(QImage, imgData);
QFETCH(QByteArray, strData);
QFETCH(QByteArray, rawData);
@@ -3499,12 +3589,13 @@ void tst_QDataStream::transaction()
QDataStream stream(&testBuffer, QIODevice::WriteOnly);
stream << i8Data << i16Data << i32Data << i64Data
- << bData << fData << dData << strData.constData();
+ << bData << fData << dData << imgData << strData.constData();
stream.writeRawData(rawData.constData(), rawData.size());
}
for (int splitPos = 0; splitPos <= testBuffer.size(); ++splitPos) {
QByteArray readBuffer(testBuffer.left(splitPos));
+
SequentialBuffer dev(&readBuffer);
dev.open(QIODevice::ReadOnly);
QDataStream stream(&dev);
@@ -3516,12 +3607,13 @@ void tst_QDataStream::transaction()
bool b;
float f;
double d;
+ QImage img;
char *str;
QByteArray raw(rawData.size(), 0);
forever {
stream.startTransaction();
- stream >> i8 >> i16 >> i32 >> i64 >> b >> f >> d >> str;
+ stream >> i8 >> i16 >> i32 >> i64 >> b >> f >> d >> img >> str;
stream.readRawData(raw.data(), raw.size());
if (stream.commitTransaction())
@@ -3543,6 +3635,7 @@ void tst_QDataStream::transaction()
QCOMPARE(b, bData);
QCOMPARE(f, fData);
QCOMPARE(d, dData);
+ QCOMPARE(img, imgData);
QVERIFY(strData == str);
delete [] str;
QCOMPARE(raw, rawData);
diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro b/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro
new file mode 100644
index 0000000000..7e003304af
--- /dev/null
+++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase
+TARGET = tst_qdatastream_core_pixmap
+QT += testlib
+SOURCES = tst_qdatastream_core_pixmap.cpp
diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
new file mode 100644
index 0000000000..c931016a61
--- /dev/null
+++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtGui/QBitmap>
+#include <QtGui/QPalette>
+#include <QtGui/QPixmap>
+#include <QtGui/QPicture>
+#include <QtGui/QTextLength>
+#include <QtGui/QPainter>
+#include <QtGui/QPen>
+
+class tst_QDataStream : public QObject
+{
+Q_OBJECT
+
+private slots:
+ void stream_with_pixmap();
+
+};
+
+void tst_QDataStream::stream_with_pixmap()
+{
+ // This is a QVariantMap with a 3x3 red QPixmap and two strings inside
+ const QByteArray ba = QByteArray::fromBase64("AAAAAwAAAAIAegAAAAoAAAAACgB0AGgAZQByAGUAAAACAHAAAABBAAAAAAGJUE5HDQoaCgAAAA1JSERSAAAAAwAAAAMIAgAAANlKIugAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAQSURBVAiZY/zPAAVMDJgsAB1bAQXZn5ieAAAAAElFTkSuQmCCAAAAAgBhAAAACgAAAAAKAGgAZQBsAGwAbw==");
+ QImage dummy; // Needed to make sure qtGui is loaded
+
+ QTest::ignoreMessage(QtWarningMsg, "QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication");
+
+ QVariantMap map;
+ QDataStream d(ba);
+ d.setVersion(QDataStream::Qt_5_12);
+ d >> map;
+
+ QCOMPARE(map["a"].toString(), QString("hello"));
+ QCOMPARE(map["p"].value<QPixmap>(), QPixmap()); // the pixmap is null because this is not a QGuiApplication
+ QCOMPARE(map["z"].toString(), QString("there"));
+}
+
+QTEST_GUILESS_MAIN(tst_QDataStream)
+
+#include "tst_qdatastream_core_pixmap.moc"
+
diff --git a/tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro b/tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro
index 4a4c091dcb..f2b5aa619f 100644
--- a/tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro
+++ b/tests/auto/corelib/serialization/qtextstream/readAllStdinProcess/readAllStdinProcess.pro
@@ -1,7 +1,6 @@
SOURCES += main.cpp
QT = core
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
DESTDIR = ./
# This app is testdata for tst_qtextstream
diff --git a/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro b/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro
index 4a4c091dcb..f2b5aa619f 100644
--- a/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro
+++ b/tests/auto/corelib/serialization/qtextstream/readLineStdinProcess/readLineStdinProcess.pro
@@ -1,7 +1,6 @@
SOURCES += main.cpp
QT = core
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
DESTDIR = ./
# This app is testdata for tst_qtextstream
diff --git a/tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro b/tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro
index 4a4c091dcb..f2b5aa619f 100644
--- a/tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro
+++ b/tests/auto/corelib/serialization/qtextstream/stdinProcess/stdinProcess.pro
@@ -1,7 +1,6 @@
SOURCES += main.cpp
QT = core
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
DESTDIR = ./
# This app is testdata for tst_qtextstream
diff --git a/tests/auto/corelib/serialization/qtextstream/test/test.pro b/tests/auto/corelib/serialization/qtextstream/test/test.pro
index 3dcfa0b414..0f289a5ce1 100644
--- a/tests/auto/corelib/serialization/qtextstream/test/test.pro
+++ b/tests/auto/corelib/serialization/qtextstream/test/test.pro
@@ -3,6 +3,8 @@ TARGET = ../tst_qtextstream
QT = core network testlib
SOURCES = ../tst_qtextstream.cpp
RESOURCES += ../qtextstream.qrc
+INCLUDEPATH += ../../../../../shared/
+HEADERS += ../../../../../shared/emulationdetector.h
win32 {
CONFIG(debug, debug|release) {
diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
index 1c1631760b..af97d4a003 100644
--- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp
@@ -44,7 +44,7 @@
# include <QProcess>
#endif
#include "../../../network-settings.h"
-
+#include "emulationdetector.h"
QT_BEGIN_NAMESPACE
template<> struct QMetaTypeId<QIODevice::OpenModeFlag>
@@ -1102,7 +1102,7 @@ void tst_QTextStream::hexTest()
QByteArray array;
QTextStream stream(&array);
- stream << showbase << hex << number;
+ stream << Qt::showbase << Qt::hex << number;
stream.flush();
QCOMPARE(array, data);
}
@@ -1132,7 +1132,7 @@ void tst_QTextStream::binTest()
QByteArray array;
QTextStream stream(&array);
- stream << showbase << bin << number;
+ stream << Qt::showbase << Qt::bin << number;
stream.flush();
QCOMPARE(array.constData(), data.constData());
}
@@ -1155,7 +1155,7 @@ void tst_QTextStream::octTest()
QByteArray array;
QTextStream stream(&array);
- stream << showbase << oct << number;
+ stream << Qt::showbase << Qt::oct << number;
stream.flush();
QCOMPARE(array, data);
}
@@ -1196,7 +1196,7 @@ void tst_QTextStream::ws_manipulator()
QTextStream stream(&string);
char a, b, c, d;
- stream >> a >> ws >> b >> ws >> c >> ws >> d;
+ stream >> a >> Qt::ws >> b >> Qt::ws >> c >> Qt::ws >> d;
QCOMPARE(a, 'a');
QCOMPARE(b, 'b');
QCOMPARE(c, 'c');
@@ -1460,6 +1460,9 @@ void tst_QTextStream::pos2()
// ------------------------------------------------------------------------------
void tst_QTextStream::pos3LargeFile()
{
+ if (EmulationDetector::isRunningArmOnX86())
+ QSKIP("Running QTextStream::pos() in tight loop is too slow on emulator");
+
{
QFile file(testFileName);
file.open(QIODevice::WriteOnly | QIODevice::Text);
@@ -1620,18 +1623,18 @@ void tst_QTextStream::forcePoint()
{
QString str;
QTextStream stream(&str);
- stream << fixed << forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
+ stream << Qt::fixed << Qt::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 << Qt::scientific << Qt::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 << Qt::forcepoint << 1.0 << ' ' << 1 << ' ' << 0 << ' ' << -1.0 << ' ' << -1;
QCOMPARE(str, QString("1.00000 1 0 -1.00000 -1"));
}
@@ -1641,7 +1644,7 @@ void tst_QTextStream::forceSign()
{
QString str;
QTextStream stream(&str);
- stream << forcesign << 1.2 << ' ' << -1.2 << ' ' << 0;
+ stream << Qt::forcesign << 1.2 << ' ' << -1.2 << ' ' << 0;
QCOMPARE(str, QString("+1.2 -1.2 +0"));
}
@@ -1660,19 +1663,22 @@ void tst_QTextStream::read0d0d0a()
Q_DECLARE_METATYPE(QTextStreamFunction);
+// Also tests that we can have namespaces that conflict with our QTextStream constants.
+namespace ws {
QTextStream &noop(QTextStream &s) { return s; }
+}
void tst_QTextStream::numeralCase_data()
{
- QTextStreamFunction noop_ = noop;
- QTextStreamFunction bin_ = bin;
- QTextStreamFunction oct_ = oct;
- QTextStreamFunction hex_ = hex;
- QTextStreamFunction base = showbase;
- QTextStreamFunction ucb = uppercasebase;
- QTextStreamFunction lcb = lowercasebase;
- QTextStreamFunction ucd = uppercasedigits;
- QTextStreamFunction lcd = lowercasedigits;
+ QTextStreamFunction noop_ = ws::noop;
+ QTextStreamFunction bin = Qt::bin;
+ QTextStreamFunction oct = Qt::oct;
+ QTextStreamFunction hex = Qt::hex;
+ QTextStreamFunction base = Qt::showbase;
+ QTextStreamFunction ucb = Qt::uppercasebase;
+ QTextStreamFunction lcb = Qt::lowercasebase;
+ QTextStreamFunction ucd = Qt::uppercasedigits;
+ QTextStreamFunction lcd = Qt::lowercasedigits;
QTest::addColumn<QTextStreamFunction>("func1");
QTest::addColumn<QTextStreamFunction>("func2");
@@ -1683,30 +1689,30 @@ void tst_QTextStream::numeralCase_data()
QTest::newRow("dec 1") << noop_ << noop_ << noop_ << noop_ << 31 << "31";
QTest::newRow("dec 2") << noop_ << base << noop_ << noop_ << 31 << "31";
- QTest::newRow("hex 1") << hex_ << noop_ << noop_ << noop_ << 31 << "1f";
- QTest::newRow("hex 2") << hex_ << noop_ << noop_ << lcd << 31 << "1f";
- QTest::newRow("hex 3") << hex_ << noop_ << ucb << noop_ << 31 << "1f";
- QTest::newRow("hex 4") << hex_ << noop_ << noop_ << ucd << 31 << "1F";
- QTest::newRow("hex 5") << hex_ << noop_ << lcb << ucd << 31 << "1F";
- QTest::newRow("hex 6") << hex_ << noop_ << ucb << ucd << 31 << "1F";
- QTest::newRow("hex 7") << hex_ << base << noop_ << noop_ << 31 << "0x1f";
- QTest::newRow("hex 8") << hex_ << base << lcb << lcd << 31 << "0x1f";
- QTest::newRow("hex 9") << hex_ << base << ucb << noop_ << 31 << "0X1f";
- QTest::newRow("hex 10") << hex_ << base << ucb << lcd << 31 << "0X1f";
- QTest::newRow("hex 11") << hex_ << base << noop_ << ucd << 31 << "0x1F";
- QTest::newRow("hex 12") << hex_ << base << lcb << ucd << 31 << "0x1F";
- QTest::newRow("hex 13") << hex_ << base << ucb << ucd << 31 << "0X1F";
-
- QTest::newRow("bin 1") << bin_ << noop_ << noop_ << noop_ << 31 << "11111";
- QTest::newRow("bin 2") << bin_ << base << noop_ << noop_ << 31 << "0b11111";
- QTest::newRow("bin 3") << bin_ << base << lcb << noop_ << 31 << "0b11111";
- QTest::newRow("bin 4") << bin_ << base << ucb << noop_ << 31 << "0B11111";
- QTest::newRow("bin 5") << bin_ << base << noop_ << ucd << 31 << "0b11111";
- QTest::newRow("bin 6") << bin_ << base << lcb << ucd << 31 << "0b11111";
- QTest::newRow("bin 7") << bin_ << base << ucb << ucd << 31 << "0B11111";
-
- QTest::newRow("oct 1") << oct_ << noop_ << noop_ << noop_ << 31 << "37";
- QTest::newRow("oct 2") << oct_ << base << noop_ << noop_ << 31 << "037";
+ QTest::newRow("hex 1") << hex << noop_ << noop_ << noop_ << 31 << "1f";
+ QTest::newRow("hex 2") << hex << noop_ << noop_ << lcd << 31 << "1f";
+ QTest::newRow("hex 3") << hex << noop_ << ucb << noop_ << 31 << "1f";
+ QTest::newRow("hex 4") << hex << noop_ << noop_ << ucd << 31 << "1F";
+ QTest::newRow("hex 5") << hex << noop_ << lcb << ucd << 31 << "1F";
+ QTest::newRow("hex 6") << hex << noop_ << ucb << ucd << 31 << "1F";
+ QTest::newRow("hex 7") << hex << base << noop_ << noop_ << 31 << "0x1f";
+ QTest::newRow("hex 8") << hex << base << lcb << lcd << 31 << "0x1f";
+ QTest::newRow("hex 9") << hex << base << ucb << noop_ << 31 << "0X1f";
+ QTest::newRow("hex 10") << hex << base << ucb << lcd << 31 << "0X1f";
+ QTest::newRow("hex 11") << hex << base << noop_ << ucd << 31 << "0x1F";
+ QTest::newRow("hex 12") << hex << base << lcb << ucd << 31 << "0x1F";
+ QTest::newRow("hex 13") << hex << base << ucb << ucd << 31 << "0X1F";
+
+ QTest::newRow("bin 1") << bin << noop_ << noop_ << noop_ << 31 << "11111";
+ QTest::newRow("bin 2") << bin << base << noop_ << noop_ << 31 << "0b11111";
+ QTest::newRow("bin 3") << bin << base << lcb << noop_ << 31 << "0b11111";
+ QTest::newRow("bin 4") << bin << base << ucb << noop_ << 31 << "0B11111";
+ QTest::newRow("bin 5") << bin << base << noop_ << ucd << 31 << "0b11111";
+ QTest::newRow("bin 6") << bin << base << lcb << ucd << 31 << "0b11111";
+ QTest::newRow("bin 7") << bin << base << ucb << ucd << 31 << "0B11111";
+
+ QTest::newRow("oct 1") << oct << noop_ << noop_ << noop_ << 31 << "37";
+ QTest::newRow("oct 2") << oct << base << noop_ << noop_ << 31 << "037";
}
void tst_QTextStream::numeralCase()
@@ -1779,9 +1785,9 @@ void tst_QTextStream::nanInf()
QString s;
QTextStream out(&s);
out << qInf() << ' ' << -qInf() << ' ' << qQNaN()
- << uppercasedigits << ' '
+ << Qt::uppercasedigits << ' '
<< qInf() << ' ' << -qInf() << ' ' << qQNaN()
- << flush;
+ << Qt::flush;
QCOMPARE(s, QString("inf -inf nan INF -INF NAN"));
}
@@ -1856,9 +1862,9 @@ void tst_QTextStream::writeSeekWriteNoBOM()
int number = 0;
QString sizeStr = QLatin1String("Size=")
+ QString::number(number).rightJustified(10, QLatin1Char('0'));
- stream << sizeStr << endl;
- stream << "Version=" << QString::number(14) << endl;
- stream << "blah blah blah" << endl;
+ stream << sizeStr << Qt::endl;
+ stream << "Version=" << QString::number(14) << Qt::endl;
+ stream << "blah blah blah" << Qt::endl;
stream.flush();
QCOMPARE(out.buffer().constData(), "Size=0000000000\nVersion=14\nblah blah blah\n");
@@ -1868,7 +1874,7 @@ void tst_QTextStream::writeSeekWriteNoBOM()
stream.seek(0);
sizeStr = QLatin1String("Size=")
+ QString::number(number).rightJustified(10, QLatin1Char('0'));
- stream << sizeStr << endl;
+ stream << sizeStr << Qt::endl;
stream.flush();
// Check buffer is still OK
diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
index 8fdf91b090..e4d50607b7 100644
--- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
@@ -253,7 +253,7 @@ public:
qFatal("%s: aId must not be an empty string", Q_FUNC_INFO);
}
- void swap(MissedBaseline &other) Q_DECL_NOTHROW
+ void swap(MissedBaseline &other) noexcept
{
qSwap(id, other.id);
qSwap(expected, other.expected);
diff --git a/tests/auto/corelib/serialization/serialization.pro b/tests/auto/corelib/serialization/serialization.pro
index 9187de1bc5..9638178cdc 100644
--- a/tests/auto/corelib/serialization/serialization.pro
+++ b/tests/auto/corelib/serialization/serialization.pro
@@ -6,6 +6,7 @@ SUBDIRS = \
qcborvalue \
qcborvalue_json \
qdatastream \
+ qdatastream_core_pixmap \
qtextstream \
qxmlstream