tst_QAnyStringView: port to QTEST_THROW_ON_FAIL
Dogfooding the new QtTest 6.8 feature. Change-Id: Ied115f33990040b92f49b319c36d20f7510e6eac Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit 757e3d77ac186988a3fe8bed9706c5792caa2666) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
df055c0256
commit
a9ebd2d64e
@ -1,7 +1,9 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
if (NOT WASM) # QTBUG-121822
|
||||
add_subdirectory(qanystringview)
|
||||
endif()
|
||||
add_subdirectory(qbytearray)
|
||||
add_subdirectory(qbytearray_large)
|
||||
add_subdirectory(qbytearrayapisymmetry)
|
||||
|
@ -14,6 +14,10 @@ endif()
|
||||
qt_internal_add_test(tst_qanystringview
|
||||
SOURCES
|
||||
tst_qanystringview.cpp
|
||||
NO_BATCH # QTBUG-121815
|
||||
DEFINES
|
||||
QTEST_THROW_ON_FAIL
|
||||
QTEST_THROW_ON_SKIP
|
||||
LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::TestPrivate
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include <deque>
|
||||
#include <list>
|
||||
|
||||
#ifndef QTEST_THROW_ON_FAIL
|
||||
# error This test requires QTEST_THROW_ON_FAIL being active.
|
||||
#endif
|
||||
|
||||
#ifdef __cpp_char8_t
|
||||
# define ONLY_IF_CHAR_8_T(expr) expr
|
||||
#else
|
||||
@ -363,8 +367,6 @@ private Q_SLOTS:
|
||||
void fromUShort() const { fromCharacter(ushort(0xE4), 1); }
|
||||
void fromChar32T() const {
|
||||
fromCharacter(U'ä', 1);
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
fromCharacter(U'\x1F0A0', 2); // U+1F0A0: PLAYING CARD BACK
|
||||
}
|
||||
void fromWCharT() const {
|
||||
@ -374,8 +376,6 @@ private Q_SLOTS:
|
||||
void fromQLatin1Char() const { fromCharacter(QLatin1Char('\xE4'), 1); }
|
||||
void fromQCharSpecialCharacter() const {
|
||||
fromCharacter(QChar::ReplacementCharacter, 1);
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
fromCharacter(QChar::LastValidCodePoint, 1);
|
||||
}
|
||||
|
||||
@ -661,20 +661,10 @@ void tst_QAnyStringView::fromQStringOrByteArray() const
|
||||
QVERIFY(!QAnyStringView(empty).isNull());
|
||||
|
||||
conversion_tests(QStringOrByteArray(Strings::oneChar));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
conversion_tests(QStringOrByteArray(Strings::twoChars));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
conversion_tests(QStringOrByteArray(Strings::threeChars));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
conversion_tests(QStringOrByteArray(Strings::regularString));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
conversion_tests(QStringOrByteArray(Strings::regularLongString));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
conversion_tests(QStringOrByteArray(Strings::stringWithNulls, Strings::stringWithNullsLength));
|
||||
}
|
||||
|
||||
@ -760,18 +750,10 @@ void tst_QAnyStringView::fromRange() const
|
||||
|
||||
doTest(reinterpret_cast<const Char *>(std::begin(Strings::regularString)),
|
||||
reinterpret_cast<const Char *>(std::end(Strings::regularString)));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
|
||||
doTest(reinterpret_cast<const Char *>(std::begin(Strings::regularLongString)),
|
||||
reinterpret_cast<const Char *>(std::end(Strings::regularLongString)));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
|
||||
doTest(reinterpret_cast<const Char *>(std::begin(Strings::stringWithNulls)),
|
||||
reinterpret_cast<const Char *>(std::end(Strings::stringWithNulls)));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
}
|
||||
|
||||
template <typename Char, typename Container>
|
||||
@ -786,8 +768,6 @@ void tst_QAnyStringView::fromContainer() const
|
||||
|
||||
std::copy(s.begin(), s.end(), std::back_inserter(c));
|
||||
conversion_tests(std::move(c));
|
||||
if (QTest::currentTestFailed())
|
||||
return;
|
||||
|
||||
// repeat with nulls
|
||||
c = {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user