tst_QCborStreamReader: port to QTEST_THROW_ON_FAIL

Dogfooding the new QtTest 6.8 feature.

Change-Id: I381af59b005433453fe8dbd982fe44ab93b9417d
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit f8cef74aeee5eb6852a32a69a36fea8dc945f2b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-01-10 16:22:48 +01:00 committed by Qt Cherry-pick Bot
parent 2b8cf058f1
commit 6f3d68e590
3 changed files with 10 additions and 24 deletions

View File

@ -2,7 +2,9 @@
# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(json)
if (NOT WASM) # QTBUG-121822
add_subdirectory(qcborstreamreader)
endif()
if(QT_FEATURE_cborstreamwriter)
add_subdirectory(qcborstreamwriter)
endif()

View File

@ -17,6 +17,10 @@ qt_internal_add_test(tst_qcborstreamreader
INCLUDE_DIRECTORIES
../../../../../src/3rdparty/tinycbor/src
../../../../../src/3rdparty/tinycbor/tests
NO_BATCH # QTBUG-121815
DEFINES
QTEST_THROW_ON_FAIL
QTEST_THROW_ON_SKIP
LIBRARIES
Qt::CorePrivate
)

View File

@ -5,6 +5,10 @@
#include <QTest>
#include <QBuffer>
#ifndef QTEST_THROW_ON_FAIL
# error This test requires QTEST_THROW_ON_FAIL being active.
#endif
class tst_QCborStreamReader : public QObject
{
Q_OBJECT
@ -627,8 +631,6 @@ void tst_QCborStreamReader::strings_data()
void tst_QCborStreamReader::strings()
{
fixed();
if (QTest::currentTestFailed())
return;
// Extra string checks:
// We'll compare the reads using readString() and readByteArray()
@ -814,9 +816,6 @@ void tst_QCborStreamReader::arrays()
removeIndicators(expected);
checkContainer(1, '\x81' + data, '[' + expected + ']');
if (QTest::currentTestFailed())
return;
checkContainer(2, '\x82' + data + data, '[' + expected + ", " + expected + ']');
}
@ -828,19 +827,11 @@ void tst_QCborStreamReader::maps()
// int keys
checkContainer(1, "\xa1\1" + data, "{1: " + expected + '}');
if (QTest::currentTestFailed())
return;
checkContainer(2, "\xa2\1" + data + '\x20' + data,
"{1: " + expected + ", -1: " + expected + '}');
if (QTest::currentTestFailed())
return;
// string keys
checkContainer(1, "\xa1\x65Hello" + data, "{\"Hello\": " + expected + '}');
if (QTest::currentTestFailed())
return;
checkContainer(2, "\xa2\x65World" + data + "\x65Hello" + data,
"{\"World\": " + expected + ", \"Hello\": " + expected + '}');
}
@ -852,9 +843,6 @@ void tst_QCborStreamReader::undefLengthArrays()
removeIndicators(expected);
checkContainer(-1, '\x9f' + data + '\xff', '[' + expected + ']');
if (QTest::currentTestFailed())
return;
checkContainer(-2, '\x9f' + data + data + '\xff', '[' + expected + ", " + expected + ']');
}
@ -866,19 +854,11 @@ void tst_QCborStreamReader::undefLengthMaps()
// int keys
checkContainer(-1, "\xbf\1" + data + '\xff', "{1: " + expected + '}');
if (QTest::currentTestFailed())
return;
checkContainer(-2, "\xbf\1" + data + '\x20' + data + '\xff',
"{1: " + expected + ", -1: " + expected + '}');
if (QTest::currentTestFailed())
return;
// string keys
checkContainer(-1, "\xbf\x65Hello" + data + '\xff', "{\"Hello\": " + expected + '}');
if (QTest::currentTestFailed())
return;
checkContainer(-2, "\xbf\x65World" + data + "\x65Hello" + data + '\xff',
"{\"World\": " + expected + ", \"Hello\": " + expected + '}');
}