summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-03-03 09:27:59 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-07 00:06:19 +0000
commita6bd11531309ad8c2773800fec5f5c67d8513ba8 (patch)
tree49c99da235a73d46ad00dda0ca3e70dd75cc3579 /tests
parentc7c52d1cefe40b765da3b1f7773829efc3805a80 (diff)
tst_qstringapisymmetry: check QString/QAnyStringView overloads w/Q_WEAK_OVERLOAD flipped
This overload set may come in handy to cushion some of the concerns regarding replacing QString functions with QAnyStringView ones. Overloading with a Q_WEAK_OVERLOAD QAnyStringView function requires users to jump through hoops in order to avoid the QString overload, but with the Q_WEAK_OVERLOAD roles reversed, the QAnyStringView overload becomes the preferred version, relegating the QString overload to a fall-back to facilitate sharing where it makes sense (e.g. for QObject::setObjectName()). Change-Id: Ic65ead505beee627976a306e2d430e800540a600 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> (cherry picked from commit 1931689c7df579375b904a71c6f9e0844492cbe2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
index 53861aab8f..ccb5e70e6f 100644
--- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
+++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
@@ -932,6 +932,14 @@ void overload_sr_a(QString &&) {}
Q_WEAK_OVERLOAD
void overload_sr_a(QAnyStringView) {}
+Q_WEAK_OVERLOAD
+void overload_a_s(const QString &) {}
+void overload_a_s(QAnyStringView) {}
+
+Q_WEAK_OVERLOAD
+void overload_a_sr(QString &&) {}
+void overload_a_sr(QAnyStringView) {}
+
void overload_s_v(const QString &) {}
void overload_s_v(QStringView) {}
@@ -967,6 +975,20 @@ void tst_QStringApiSymmetry::overload()
overload_sr_a(CT());
}
+ overload_a_s(t);
+ overload_a_s(ct);
+ if constexpr (!std::is_array_v<T>) {
+ overload_a_s(T());
+ overload_a_s(CT());
+ }
+
+ overload_a_sr(t);
+ overload_a_sr(ct);
+ if constexpr (!std::is_array_v<T>) {
+ overload_a_sr(T());
+ overload_a_sr(CT());
+ }
+
if constexpr (std::is_convertible_v<T, QStringView> || std::is_convertible_v<T, QString>) {
overload_s_v(t);
overload_s_v(ct);