tst_moc: fix the order of arguments in QCOMPARE in checkEnum
QCOMPARE is (actual, expected). Take the opportunity to test out-of-range returns from QMetaEnum too. Change-Id: I8a96935cf6c742259c9dfffd17e9575a6d4cf90a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e3e44e2294c06f243838dfa28ec4f350c5e6ffbb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3d90aa1771
commit
46ef4c8b86
@ -4130,16 +4130,19 @@ void tst_Moc::optionsFileError()
|
||||
}
|
||||
|
||||
static void checkEnum(const QMetaEnum &enumerator, const QByteArray &name,
|
||||
const QList<QPair<QByteArray, int>> &keys,
|
||||
const QList<QPair<QByteArray, quint64>> &keys,
|
||||
const QMetaType underlyingType = QMetaType::fromType<int>())
|
||||
{
|
||||
QCOMPARE(name, QByteArray{enumerator.name()});
|
||||
QCOMPARE(keys.size(), enumerator.keyCount());
|
||||
QCOMPARE(underlyingType, enumerator.metaType().underlyingType());
|
||||
QCOMPARE(enumerator.name(), QByteArrayView{name});
|
||||
QCOMPARE(enumerator.keyCount(), keys.size());
|
||||
QCOMPARE(enumerator.metaType().underlyingType(), underlyingType);
|
||||
for (int i = 0; i < enumerator.keyCount(); ++i) {
|
||||
QCOMPARE(keys[i].first, QByteArray{enumerator.key(i)});
|
||||
QCOMPARE(keys[i].second, enumerator.value(i));
|
||||
QCOMPARE(QByteArray{enumerator.key(i)}, keys[i].first);
|
||||
QCOMPARE(enumerator.value(i), keys[i].second);
|
||||
}
|
||||
// out of range
|
||||
QVERIFY(!enumerator.key(keys.size()));
|
||||
QCOMPARE(enumerator.value(keys.size()), -1);
|
||||
}
|
||||
|
||||
class EnumFromNamespaceClass : public QObject
|
||||
|
Loading…
x
Reference in New Issue
Block a user