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:
parent
2b8cf058f1
commit
6f3d68e590
@ -2,7 +2,9 @@
|
|||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
add_subdirectory(json)
|
add_subdirectory(json)
|
||||||
|
if (NOT WASM) # QTBUG-121822
|
||||||
add_subdirectory(qcborstreamreader)
|
add_subdirectory(qcborstreamreader)
|
||||||
|
endif()
|
||||||
if(QT_FEATURE_cborstreamwriter)
|
if(QT_FEATURE_cborstreamwriter)
|
||||||
add_subdirectory(qcborstreamwriter)
|
add_subdirectory(qcborstreamwriter)
|
||||||
endif()
|
endif()
|
||||||
|
@ -17,6 +17,10 @@ qt_internal_add_test(tst_qcborstreamreader
|
|||||||
INCLUDE_DIRECTORIES
|
INCLUDE_DIRECTORIES
|
||||||
../../../../../src/3rdparty/tinycbor/src
|
../../../../../src/3rdparty/tinycbor/src
|
||||||
../../../../../src/3rdparty/tinycbor/tests
|
../../../../../src/3rdparty/tinycbor/tests
|
||||||
|
NO_BATCH # QTBUG-121815
|
||||||
|
DEFINES
|
||||||
|
QTEST_THROW_ON_FAIL
|
||||||
|
QTEST_THROW_ON_SKIP
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
Qt::CorePrivate
|
Qt::CorePrivate
|
||||||
)
|
)
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
|
#ifndef QTEST_THROW_ON_FAIL
|
||||||
|
# error This test requires QTEST_THROW_ON_FAIL being active.
|
||||||
|
#endif
|
||||||
|
|
||||||
class tst_QCborStreamReader : public QObject
|
class tst_QCborStreamReader : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -627,8 +631,6 @@ void tst_QCborStreamReader::strings_data()
|
|||||||
void tst_QCborStreamReader::strings()
|
void tst_QCborStreamReader::strings()
|
||||||
{
|
{
|
||||||
fixed();
|
fixed();
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Extra string checks:
|
// Extra string checks:
|
||||||
// We'll compare the reads using readString() and readByteArray()
|
// We'll compare the reads using readString() and readByteArray()
|
||||||
@ -814,9 +816,6 @@ void tst_QCborStreamReader::arrays()
|
|||||||
removeIndicators(expected);
|
removeIndicators(expected);
|
||||||
|
|
||||||
checkContainer(1, '\x81' + data, '[' + expected + ']');
|
checkContainer(1, '\x81' + data, '[' + expected + ']');
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
checkContainer(2, '\x82' + data + data, '[' + expected + ", " + expected + ']');
|
checkContainer(2, '\x82' + data + data, '[' + expected + ", " + expected + ']');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -828,19 +827,11 @@ void tst_QCborStreamReader::maps()
|
|||||||
|
|
||||||
// int keys
|
// int keys
|
||||||
checkContainer(1, "\xa1\1" + data, "{1: " + expected + '}');
|
checkContainer(1, "\xa1\1" + data, "{1: " + expected + '}');
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
checkContainer(2, "\xa2\1" + data + '\x20' + data,
|
checkContainer(2, "\xa2\1" + data + '\x20' + data,
|
||||||
"{1: " + expected + ", -1: " + expected + '}');
|
"{1: " + expected + ", -1: " + expected + '}');
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// string keys
|
// string keys
|
||||||
checkContainer(1, "\xa1\x65Hello" + data, "{\"Hello\": " + expected + '}');
|
checkContainer(1, "\xa1\x65Hello" + data, "{\"Hello\": " + expected + '}');
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
checkContainer(2, "\xa2\x65World" + data + "\x65Hello" + data,
|
checkContainer(2, "\xa2\x65World" + data + "\x65Hello" + data,
|
||||||
"{\"World\": " + expected + ", \"Hello\": " + expected + '}');
|
"{\"World\": " + expected + ", \"Hello\": " + expected + '}');
|
||||||
}
|
}
|
||||||
@ -852,9 +843,6 @@ void tst_QCborStreamReader::undefLengthArrays()
|
|||||||
removeIndicators(expected);
|
removeIndicators(expected);
|
||||||
|
|
||||||
checkContainer(-1, '\x9f' + data + '\xff', '[' + expected + ']');
|
checkContainer(-1, '\x9f' + data + '\xff', '[' + expected + ']');
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
checkContainer(-2, '\x9f' + data + data + '\xff', '[' + expected + ", " + expected + ']');
|
checkContainer(-2, '\x9f' + data + data + '\xff', '[' + expected + ", " + expected + ']');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,19 +854,11 @@ void tst_QCborStreamReader::undefLengthMaps()
|
|||||||
|
|
||||||
// int keys
|
// int keys
|
||||||
checkContainer(-1, "\xbf\1" + data + '\xff', "{1: " + expected + '}');
|
checkContainer(-1, "\xbf\1" + data + '\xff', "{1: " + expected + '}');
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
checkContainer(-2, "\xbf\1" + data + '\x20' + data + '\xff',
|
checkContainer(-2, "\xbf\1" + data + '\x20' + data + '\xff',
|
||||||
"{1: " + expected + ", -1: " + expected + '}');
|
"{1: " + expected + ", -1: " + expected + '}');
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// string keys
|
// string keys
|
||||||
checkContainer(-1, "\xbf\x65Hello" + data + '\xff', "{\"Hello\": " + expected + '}');
|
checkContainer(-1, "\xbf\x65Hello" + data + '\xff', "{\"Hello\": " + expected + '}');
|
||||||
if (QTest::currentTestFailed())
|
|
||||||
return;
|
|
||||||
|
|
||||||
checkContainer(-2, "\xbf\x65World" + data + "\x65Hello" + data + '\xff',
|
checkContainer(-2, "\xbf\x65World" + data + "\x65Hello" + data + '\xff',
|
||||||
"{\"World\": " + expected + ", \"Hello\": " + expected + '}');
|
"{\"World\": " + expected + ", \"Hello\": " + expected + '}');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user