Add QByteArray vs QByteArrayView relational operators

... by using the new comparison helper macors.

This allows to enable related tests in tst_qstringapisymmetry.

Task-number: QTBUG-108805
Change-Id: I2cef8f4a25889b74a921fea47995d59c3a49d368
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ivan Solovev 2024-02-12 18:46:51 +01:00
parent 9b945b381a
commit 1f92ff3ee0
2 changed files with 11 additions and 4 deletions

View File

@ -9,6 +9,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qarraydata.h>
#include <QtCore/qarraydatapointer.h>
#include <QtCore/qcompare.h>
#include <QtCore/qcontainerfwd.h>
#include <QtCore/qbytearrayalgorithms.h>
#include <QtCore/qbytearrayview.h>
@ -539,6 +540,16 @@ public:
explicit inline QByteArray(DataPointer &&dd) : d(std::move(dd)) {}
private:
friend bool comparesEqual(const QByteArray &lhs, const QByteArrayView &rhs) noexcept
{ return QByteArrayView(lhs) == rhs; }
friend Qt::strong_ordering
compareThreeWay(const QByteArray &lhs, const QByteArrayView &rhs) noexcept
{
const int res = QtPrivate::compareMemory(QByteArrayView(lhs), rhs);
return Qt::compareThreeWay(res, 0);
}
Q_DECLARE_STRONGLY_ORDERED(QByteArray, QByteArrayView)
void reallocData(qsizetype alloc, QArrayData::AllocationOption option);
void reallocGrowData(qsizetype n);
void expand(qsizetype i);

View File

@ -297,10 +297,8 @@ 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 *>(); }
@ -318,10 +316,8 @@ private Q_SLOTS:
void compare_QByteArrayView_QUtf8StringView() { compare_impl<QByteArrayView, QUtf8StringView>(); }
void compare_QByteArrayView_QLatin1String_data() { compare_data(); }
void compare_QByteArrayView_QLatin1String() { compare_impl<QByteArrayView, QLatin1String>(); }
#ifdef AMBIGUOUS_CALL
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