tst_QStringApiSymmetry: add checks for QByteArrayView

... where checks for QByteArray existed before.

The checks we can't add are
- left/right/mid (legacy APIs not implemented in QBAV)
- several relational operators, d/t ambiguities. Created
  QTBUG-108805 to track these.

Task-number: QTBUG-108805
Pick-to: 6.4 6.2
Change-Id: I30cc9b29a228d69d32af51234f2c28221478a75c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2022-11-23 18:32:41 +01:00
parent 13293d3308
commit 5812c36cd5

View File

@ -130,6 +130,7 @@ private Q_SLOTS:
void overload_QAnyStringView() { overload<QAnyStringView>(); }
void overload_QLatin1String() { overload<QLatin1String>(); }
void overload_QByteArray() { overload<QByteArray>(); }
void overload_QByteArrayView() { overload<QByteArrayView>(); }
void overload_const_char_star() { overload<const char*>(); }
void overload_const_char8_t_star() { IF_CHAR8T(overload<const char8_t*>()); }
void overload_const_char16_t_star() { overload<const char16_t*>(); }
@ -160,7 +161,7 @@ private:
void compare_impl() const;
private Q_SLOTS:
// test all combinations of {QChar, char16_t, QString, QStringView, QLatin1String, QByteArray, const char*}
// test all combinations of {QChar, char16_t, QString, QStringView, QLatin1String, QByteArray/View, const char*}
void compare_QChar_QChar_data() { compare_data(false); }
void compare_QChar_QChar() { compare_impl<QChar, QChar>(); }
void compare_QChar_char16_t_data() { compare_data(false); }
@ -175,6 +176,8 @@ private Q_SLOTS:
void compare_QChar_QLatin1String() { compare_impl<QChar, QLatin1String>(); }
void compare_QChar_QByteArray_data() { compare_data(false); }
void compare_QChar_QByteArray() { compare_impl<QChar, QByteArray>(); }
void compare_QChar_QByteArrayView_data() { compare_data(false); }
void compare_QChar_QByteArrayView() { compare_impl<QChar, QByteArrayView>(); }
void compare_QChar_const_char_star_data() { compare_data(false); }
void compare_QChar_const_char_star() { compare_impl<QChar, const char *>(); }
@ -192,6 +195,8 @@ private Q_SLOTS:
void compare_char16_t_QLatin1String() { compare_impl<char16_t, QLatin1String>(); }
void compare_char16_t_QByteArray_data() { compare_data(false); }
void compare_char16_t_QByteArray() { compare_impl<char16_t, QByteArray>(); }
void compare_char16_t_QByteArrayView_data() { compare_data(false); }
void compare_char16_t_QByteArrayView() { compare_impl<char16_t, QByteArrayView>(); }
//void compare_char16_t_const_char_star_data() { compare_data(false); }
//void compare_char16_t_const_char_star() { compare_impl<char16_t, const char *>(); }
@ -209,6 +214,8 @@ private Q_SLOTS:
void compare_QString_QLatin1String() { compare_impl<QString, QLatin1String>(); }
void compare_QString_QByteArray_data() { compare_data(); }
void compare_QString_QByteArray() { compare_impl<QString, QByteArray>(); }
void compare_QString_QByteArrayView_data() { compare_data(); }
void compare_QString_QByteArrayView() { compare_impl<QString, QByteArrayView>(); }
void compare_QString_const_char_star_data() { compare_data(); }
void compare_QString_const_char_star() { compare_impl<QString, const char *>(); }
@ -227,6 +234,8 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLMENTED
void compare_QStringView_QByteArray_data() { compare_data(); }
void compare_QStringView_QByteArray() { compare_impl<QStringView, QByteArray>(); }
void compare_QStringView_QByteArrayView_data() { compare_data(); }
void compare_QStringView_QByteArrayView() { compare_impl<QStringView, QByteArrayView>(); }
void compare_QStringView_const_char_star_data() { compare_data(); }
void compare_QStringView_const_char_star() { compare_impl<QStringView, const char *>(); }
#endif
@ -246,6 +255,8 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLMENTED
void compare_QUtf8StringView_QByteArray_data() { compare_data(); }
void compare_QUtf8StringView_QByteArray() { compare_impl<QUtf8StringView, QByteArray>(); }
void compare_QUtf8StringView_QByteArrayView_data() { compare_data(); }
void compare_QUtf8StringView_QByteArrayView() { compare_impl<QUtf8StringView, QByteArrayView>(); }
void compare_QUtf8StringView_const_char_star_data() { compare_data(); }
void compare_QUtf8StringView_const_char_star() { compare_impl<QUtf8StringView, const char *>(); }
#endif
@ -264,6 +275,10 @@ private Q_SLOTS:
void compare_QLatin1String_QLatin1String() { compare_impl<QLatin1String, QLatin1String>(); }
void compare_QLatin1String_QByteArray_data() { compare_data(); }
void compare_QLatin1String_QByteArray() { compare_impl<QLatin1String, QByteArray>(); }
#ifdef AMBIGUOUS_CALL
void compare_QLatin1String_QByteArrayView_data() { compare_data(); }
void compare_QLatin1String_QByteArrayView() { compare_impl<QLatin1String, QByteArrayView>(); }
#endif
void compare_QLatin1String_const_char_star_data() { compare_data(); }
void compare_QLatin1String_const_char_star() { compare_impl<QLatin1String, const char *>(); }
@ -283,9 +298,38 @@ private Q_SLOTS:
void compare_QByteArray_QLatin1String() { compare_impl<QByteArray, QLatin1String>(); }
void compare_QByteArray_QByteArray_data() { compare_data(); }
void compare_QByteArray_QByteArray() { compare_impl<QByteArray, QByteArray>(); }
#ifdef AMBIGUOUS_CALL
void compare_QByteArray_QByteArrayView_data() { compare_data(); }
void compare_QByteArray_QByteArrayView() { compare_impl<QByteArray, QByteArrayView>(); }
#endif
void compare_QByteArray_const_char_star_data() { compare_data(); }
void compare_QByteArray_const_char_star() { compare_impl<QByteArray, const char *>(); }
void compare_QByteArrayView_QChar_data() { compare_data(false); }
void compare_QByteArrayView_QChar() { compare_impl<QByteArrayView, QChar>(); }
void compare_QByteArrayView_char16_t_data() { compare_data(false); }
void compare_QByteArrayView_char16_t() { compare_impl<QByteArrayView, char16_t>(); }
void compare_QByteArrayView_QString_data() { compare_data(); }
void compare_QByteArrayView_QString() { compare_impl<QByteArrayView, QString>(); }
#ifdef NOT_YET_IMPLEMENTED
void compare_QByteArrayView_QStringView_data() { compare_data(); }
void compare_QByteArrayView_QStringView() { compare_impl<QByteArrayView, QStringView>(); }
#endif
#ifdef AMBIGUOUS_CALL
void compare_QByteArrayView_QUtf8StringView_data() { compare_data(); }
void compare_QByteArrayView_QUtf8StringView() { compare_impl<QByteArrayView, QUtf8StringView>(); }
void compare_QByteArrayView_QLatin1String_data() { compare_data(); }
void compare_QByteArrayView_QLatin1String() { compare_impl<QByteArrayView, QLatin1String>(); }
void compare_QByteArrayView_QByteArray_data() { compare_data(); }
void compare_QByteArrayView_QByteArray() { compare_impl<QByteArrayView, QByteArray>(); }
#endif
void compare_QByteArrayView_QByteArrayView_data() { compare_data(); }
void compare_QByteArrayView_QByteArrayView() { compare_impl<QByteArrayView, QByteArrayView>(); }
#ifdef AMBIGUOUS_CALL
void compare_QByteArrayView_const_char_star_data() { compare_data(); }
void compare_QByteArrayView_const_char_star() { compare_impl<QByteArrayView, const char *>(); }
#endif
void compare_const_char_star_QChar_data() { compare_data(false); }
void compare_const_char_star_QChar() { compare_impl<const char *, QChar>(); }
//void compare_const_char_star_char16_t_data() { compare_data(false); }
@ -298,6 +342,10 @@ private Q_SLOTS:
void compare_const_char_star_QLatin1String() { compare_impl<const char *, QLatin1String>(); }
void compare_const_char_star_QByteArray_data() { compare_data(); }
void compare_const_char_star_QByteArray() { compare_impl<const char *, QByteArray>(); }
#ifdef AMBIGUOUS_CALL
void compare_const_char_star_QByteArrayView_data() { compare_data(); }
void compare_const_char_star_QByteArrayView() { compare_impl<const char *, QByteArrayView>(); }
#endif
//void compare_const_char_star_const_char_star_data() { compare_data(); }
//void compare_const_char_star_const_char_star() { compare_impl<const char *, const char *>(); }
@ -321,6 +369,8 @@ private Q_SLOTS:
void member_compare_QChar_QLatin1String() { member_compare_impl<QChar, QLatin1String>(); }
void member_compare_QChar_QByteArray_data() { member_compare_data(false); }
void member_compare_QChar_QByteArray() { member_compare_impl<QChar, QByteArray>(); }
void member_compare_QChar_QByteArrayView_data() { member_compare_data(false); }
void member_compare_QChar_QByteArrayView() { member_compare_impl<QChar, QByteArrayView>(); }
void member_compare_QChar_const_char_star_data() { member_compare_data(false); }
void member_compare_QChar_const_char_star() { member_compare_impl<QChar, const char *>(); }
#endif
@ -339,6 +389,10 @@ private Q_SLOTS:
void member_compare_QString_QLatin1String() { member_compare_impl<QString, QLatin1String>(); }
void member_compare_QString_QByteArray_data() { member_compare_data(); }
void member_compare_QString_QByteArray() { member_compare_impl<QString, QByteArray>(); }
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QString_QByteArrayView_data() { member_compare_data(); }
void member_compare_QString_QByteArrayView() { member_compare_impl<QString, QByteArrayView>(); }
#endif
void member_compare_QString_const_char_star_data() { member_compare_data(); }
void member_compare_QString_const_char_star() { member_compare_impl<QString, const char *>(); }
@ -355,6 +409,8 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QStringView_QByteArray_data() { member_compare_data(); }
void member_compare_QStringView_QByteArray() { member_compare_impl<QStringView, QByteArray>(); }
void member_compare_QStringView_QByteArrayView_data() { member_compare_data(); }
void member_compare_QStringView_QByteArrayView() { member_compare_impl<QStringView, QByteArrayView>(); }
void member_compare_QStringView_const_char_star_data() { member_compare_data(); }
void member_compare_QStringView_const_char_star() { member_compare_impl<QStringView, const char *>(); }
#endif
@ -374,9 +430,13 @@ private Q_SLOTS:
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QLatin1String_QByteArray_data() { member_compare_data(); }
void member_compare_QLatin1String_QByteArray() { member_compare_impl<QLatin1String, QByteArray>(); }
void member_compare_QLatin1String_QByteArrayView_data() { member_compare_data(); }
void member_compare_QLatin1String_QByteArrayView() { member_compare_impl<QLatin1String, QByteArrayView>(); }
void member_compare_QLatin1String_const_char_star_data() { member_compare_data(); }
void member_compare_QLatin1String_const_char_star() { member_compare_impl<QLatin1String, const char *>(); }
#endif
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QByteArray_QChar_data() { member_compare_data(false); }
void member_compare_QByteArray_QChar() { member_compare_impl<QByteArray, QChar>(); }
void member_compare_QByteArray_char16_t_data() { member_compare_data(false); }
@ -388,9 +448,28 @@ private Q_SLOTS:
#endif
void member_compare_QByteArray_QByteArray_data() { member_compare_data(); }
void member_compare_QByteArray_QByteArray() { member_compare_impl<QByteArray, QByteArray>(); }
void member_compare_QByteArray_QByteArrayView_data() { member_compare_data(); }
void member_compare_QByteArray_QByteArrayView() { member_compare_impl<QByteArray, QByteArrayView>(); }
void member_compare_QByteArray_const_char_star_data() { member_compare_data(); }
void member_compare_QByteArray_const_char_star() { member_compare_impl<QByteArray, const char *>(); }
#ifdef NOT_YET_IMPLEMENTED
void member_compare_QByteArrayView_QChar_data() { member_compare_data(false); }
void member_compare_QByteArrayView_QChar() { member_compare_impl<QByteArrayView, QChar>(); }
void member_compare_QByteArrayView_char16_t_data() { member_compare_data(false); }
void member_compare_QByteArrayView_char16_t() { member_compare_impl<QByteArrayView, char16_t>(); }
void member_compare_QByteArrayView_QString_data() { member_compare_data(); }
void member_compare_QByteArrayView_QString() { member_compare_impl<QByteArrayView, QString>(); }
void member_compare_QByteArrayView_QLatin1String_data() { member_compare_data(); }
void member_compare_QByteArrayView_QLatin1String() { member_compare_impl<QByteArrayView, QLatin1String>(); }
#endif
void member_compare_QByteArrayView_QByteArray_data() { member_compare_data(); }
void member_compare_QByteArrayView_QByteArray() { member_compare_impl<QByteArrayView, QByteArray>(); }
void member_compare_QByteArrayView_QByteArrayView_data() { member_compare_data(); }
void member_compare_QByteArrayView_QByteArrayView() { member_compare_impl<QByteArrayView, QByteArrayView>(); }
void member_compare_QByteArrayView_const_char_star_data() { member_compare_data(); }
void member_compare_QByteArrayView_const_char_star() { member_compare_impl<QByteArrayView, const char *>(); }
private:
void localeAwareCompare_data();
template<typename LHS, typename RHS>
@ -667,6 +746,8 @@ private Q_SLOTS:
void sliced_QUtf8StringView() { sliced_impl<QUtf8StringView>(); }
void sliced_QByteArray_data() { sliced_data(); }
void sliced_QByteArray() { sliced_impl<QByteArray>(); }
void sliced_QByteArrayView_data() { sliced_data(); }
void sliced_QByteArrayView() { sliced_impl<QByteArrayView>(); }
void first_truncate_QString_data() { first_data(); }
void first_truncate_QString() { first_impl<QString>(); }
@ -678,6 +759,8 @@ private Q_SLOTS:
void first_truncate_QUtf8StringView() { first_impl<QUtf8StringView>(); }
void first_truncate_QByteArray_data() { first_data(); }
void first_truncate_QByteArray() { first_impl<QByteArray>(); }
void first_truncate_QByteArrayView_data() { first_data(); }
void first_truncate_QByteArrayView() { first_impl<QByteArrayView>(); }
void last_QString_data() { last_data(); }
void last_QString() { last_impl<QString>(); }
@ -689,6 +772,8 @@ private Q_SLOTS:
void last_QUtf8StringView() { last_impl<QUtf8StringView>(); }
void last_QByteArray_data() { last_data(); }
void last_QByteArray() { last_impl<QByteArray>(); }
void last_QByteArrayView_data() { last_data(); }
void last_QByteArrayView() { last_impl<QByteArrayView>(); }
void chop_QString_data() { chop_data(); }
void chop_QString() { chop_impl<QString>(); }
@ -700,6 +785,8 @@ private Q_SLOTS:
void chop_QLatin1String() { chop_impl<QLatin1String>(); }
void chop_QByteArray_data() { chop_data(); }
void chop_QByteArray() { chop_impl<QByteArray>(); }
void chop_QByteArrayView_data() { chop_data(); }
void chop_QByteArrayView() { chop_impl<QByteArrayView>(); }
private:
void trimmed_data();
@ -714,6 +801,8 @@ private Q_SLOTS:
void trim_trimmed_QLatin1String() { trimmed_impl<QLatin1String>(); }
void trim_trimmed_QByteArray_data() { trimmed_data(); }
void trim_trimmed_QByteArray() { trimmed_impl<QByteArray>(); }
void trim_trimmed_QByteArrayView_data() { trimmed_data(); }
void trim_trimmed_QByteArrayView() { trimmed_impl<QByteArrayView>(); }
private:
void toNumber_data();
@ -726,19 +815,23 @@ private Q_SLOTS:
void toNumber_QString() { toNumber_impl<QString>(); }
void toNumber_QStringView_data() { toNumber_data(); }
void toNumber_QStringView() { toNumber_impl<QStringView>(); }
void toNumber_QByteArray_data() { toNumber_data(); }
void toNumber_QByteArray() { toNumber_impl<QByteArray>(); }
void toNumber_QLatin1String_data() { toNumber_data(); }
void toNumber_QLatin1String() { toNumber_impl<QLatin1String>(); }
void toNumber_QByteArray_data() { toNumber_data(); }
void toNumber_QByteArray() { toNumber_impl<QByteArray>(); }
void toNumber_QByteArrayView_data() { toNumber_data(); }
void toNumber_QByteArrayView() { toNumber_impl<QByteArrayView>(); }
void toNumberWithBases_QString_data() { toNumberWithBases_data(); }
void toNumberWithBases_QString() { toNumberWithBases_impl<QString>(); }
void toNumberWithBases_QStringView_data() { toNumberWithBases_data(); }
void toNumberWithBases_QStringView() { toNumberWithBases_impl<QStringView>(); }
void toNumberWithBases_QByteArray_data() { toNumberWithBases_data(); }
void toNumberWithBases_QByteArray() { toNumberWithBases_impl<QByteArray>(); }
void toNumberWithBases_QLatin1String_data() { toNumberWithBases_data(); }
void toNumberWithBases_QLatin1String() { toNumberWithBases_impl<QLatin1String>(); }
void toNumberWithBases_QByteArray_data() { toNumberWithBases_data(); }
void toNumberWithBases_QByteArray() { toNumberWithBases_impl<QByteArray>(); }
void toNumberWithBases_QByteArrayView_data() { toNumberWithBases_data(); }
void toNumberWithBases_QByteArrayView() { toNumberWithBases_impl<QByteArrayView>(); }
private:
void count_data();
@ -1179,6 +1272,7 @@ MAKE(QString) { return sv.toString(); }
MAKE(QStringView) { return sv; }
MAKE(QLatin1String) { return l1; }
MAKE(QByteArray) { return u8; }
MAKE(QByteArrayView) { return u8; }
MAKE(const char *) { return u8.data(); }
MAKE(const char16_t *) { return sv.utf16(); } // assumes `sv` doesn't represent a substring
MAKE(std::u16string) { return sv.toString().toStdU16String(); }
@ -1193,6 +1287,7 @@ MAKE(QAnyStringViewUsingU16) { return {QAnyStringView{sv}}; }
template <typename> constexpr bool is_bytearray_like_v = false;
template <> constexpr bool is_bytearray_like_v<const char *> = true;
template <> constexpr bool is_bytearray_like_v<QByteArray> = true;
template <> constexpr bool is_bytearray_like_v<QByteArrayView> = true;
template <typename LHS, typename RHS>
constexpr bool has_nothrow_member_compare_v = is_bytearray_like_v<LHS> == is_bytearray_like_v<RHS>;