From 1e51b8ac7b9af6d9cb2a75ee537a7873ab6d73f3 Mon Sep 17 00:00:00 2001 From: Matthias Rauter Date: Mon, 26 May 2025 13:08:55 +0200 Subject: [PATCH] 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.8 Change-Id: Id8f2c1c5690f7219ac000eebb637f48acbc5662d Reviewed-by: Thiago Macieira (cherry picked from commit 1ecbad8da9828dc561268d0fce8c24239f0a7f2d) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/text/qstringview/CMakeLists.txt | 1 + tests/auto/corelib/text/qstringview/tst_qstringview.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/text/qstringview/CMakeLists.txt b/tests/auto/corelib/text/qstringview/CMakeLists.txt index 3e02d2ec05c..be6a05d3405 100644 --- a/tests/auto/corelib/text/qstringview/CMakeLists.txt +++ b/tests/auto/corelib/text/qstringview/CMakeLists.txt @@ -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) diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp index 237abcc498d..a5d0b26bc00 100644 --- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #if QT_CONFIG(cpp_winrt) # include #endif @@ -423,9 +424,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 @@ -885,6 +884,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);