Add equality comparison between QJsonObject and QJsonValueConstRef
- amends 839cffd5212cc1437661e9c650eb2ff4b19fa4e8 Fixes: QTBUG-123927 Change-Id: I9174e747478937d4c9ed6522dd603fea50daf203 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
f62a6ac874
commit
faaee82129
@ -32,7 +32,7 @@ QT_BEGIN_NAMESPACE
|
||||
\brief The QJsonObject class encapsulates a JSON object.
|
||||
|
||||
\compares equality
|
||||
\compareswith equality QJsonValue
|
||||
\compareswith equality QJsonValue QJsonValueConstRef
|
||||
\endcompareswith
|
||||
|
||||
A JSON object is a list of key value pairs, where the keys are unique strings
|
||||
|
@ -244,8 +244,14 @@ private:
|
||||
{
|
||||
return comparesEqual(lhs, rhs.toObject());
|
||||
}
|
||||
friend bool comparesEqual(const QJsonObject &lhs,
|
||||
const QJsonValueConstRef &rhs) noexcept
|
||||
{
|
||||
return comparesEqual(lhs, rhs.toObject());
|
||||
}
|
||||
Q_DECLARE_EQUALITY_COMPARABLE(QJsonObject)
|
||||
Q_DECLARE_EQUALITY_COMPARABLE(QJsonObject, QJsonValue)
|
||||
Q_DECLARE_EQUALITY_COMPARABLE(QJsonObject, QJsonValueConstRef)
|
||||
friend class QJsonValue;
|
||||
friend class QJsonDocument;
|
||||
friend class QJsonPrivate::Value;
|
||||
|
@ -187,6 +187,8 @@ void tst_QtJson::compareCompiles()
|
||||
QTestPrivate::testEqualityOperatorsCompile<QJsonValueRef>();
|
||||
QTestPrivate::testEqualityOperatorsCompile<QJsonArray, QJsonValue>();
|
||||
QTestPrivate::testEqualityOperatorsCompile<QJsonObject, QJsonValue>();
|
||||
QTestPrivate::testEqualityOperatorsCompile<QJsonObject, QJsonValueConstRef>();
|
||||
QTestPrivate::testEqualityOperatorsCompile<QJsonObject, QJsonValueRef>();
|
||||
QTestPrivate::testEqualityOperatorsCompile<QJsonValueConstRef, QJsonValue>();
|
||||
QTestPrivate::testEqualityOperatorsCompile<QJsonValueRef, QJsonValue>();
|
||||
QTestPrivate::testEqualityOperatorsCompile<QJsonValueRef, QJsonValueConstRef>();
|
||||
@ -670,6 +672,7 @@ void tst_QtJson::testObjectInsertCopies()
|
||||
QCOMPARE(obj.size(), 2);
|
||||
QCOMPARE(obj.value("value"), "TEST");
|
||||
QCOMPARE(obj.value("prop2"), "TEST");
|
||||
QT_TEST_EQUALITY_OPS(rv, obj["value"].toObject(), true);
|
||||
}
|
||||
{
|
||||
QJsonObject obj;
|
||||
|
Loading…
x
Reference in New Issue
Block a user