Add TEST_ALL_COMPARISON to tst_qstringview

While porting some of these tests to QUtf8StringView, Thiago suggested
to add the comparison tests from qcomparisontesthelper_p.h.

Pick-to: 6.9 6.8
Change-Id: Id8f2c1c5690f7219ac000eebb637f48acbc5662d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Matthias Rauter 2025-05-26 13:08:55 +02:00
parent deec49bac6
commit 1ecbad8da9
2 changed files with 6 additions and 3 deletions

View File

@ -17,6 +17,7 @@ qt_internal_add_test(tst_qstringview
arrays_of_unknown_bounds.cpp arrays_of_unknown_bounds.h
LIBRARIES
Qt::CorePrivate
Qt::TestPrivate
)
if(QT_FEATURE_sanitize_undefined)

View File

@ -9,6 +9,7 @@
#include <QChar>
#include <QVarLengthArray>
#include <QList>
#include <private/qcomparisontesthelper_p.h>
#if QT_CONFIG(cpp_winrt)
# include <private/qt_winrtbase_p.h>
#endif
@ -424,9 +425,7 @@ void tst_QStringView::basics() const
QVERIFY(sv1.isEmpty());
QStringView sv2;
QVERIFY(sv2 == sv1);
QVERIFY(!(sv2 != sv1));
QT_TEST_ALL_COMPARISON_OPS(sv2, sv1, Qt::strong_ordering::equal);
}
void tst_QStringView::literals() const
@ -886,6 +885,9 @@ void tst_QStringView::comparison()
QVERIFY(aa < bb);
QVERIFY(bb > aa);
QT_TEST_ALL_COMPARISON_OPS(aa, aa, Qt::strong_ordering::equal);
QT_TEST_ALL_COMPARISON_OPS(aa, bb, Qt::strong_ordering::less);
QCOMPARE(aa.compare(aa), 0);
QVERIFY(aa.compare(upperAa) != 0);
QCOMPARE(aa.compare(upperAa, Qt::CaseInsensitive), 0);