diff options
Diffstat (limited to 'tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp')
-rw-r--r-- | tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp index 93e0d6fce8..acfd60e224 100644 --- a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <QTestEventLoop> @@ -15,6 +15,7 @@ class tst_QBuffer : public QObject Q_OBJECT private slots: void open(); + void openWriteOnlyDoesNotTruncate(); void getSetCheck(); void readBlock(); void readBlockPastEnd(); @@ -111,6 +112,29 @@ void tst_QBuffer::open() b.close(); } +void tst_QBuffer::openWriteOnlyDoesNotTruncate() +{ + QBuffer b; + const auto data = QByteArrayLiteral("Hey, presto!"); + + { + QVERIFY(b.open(QIODevice::WriteOnly)); + b.write(data); + b.close(); + } + { + QVERIFY(b.open(QIODevice::ReadOnly)); + QCOMPARE(b.readAll(), data); + b.close(); + } + { + QVERIFY(b.open(QIODevice::WriteOnly)); + QCOMPARE(b.size(), data.size()); + QCOMPARE(b.pos(), 0); + b.close(); + } +} + // some status() tests, too void tst_QBuffer::readBlock() { |