From 5a2aa12147577b1747704bf06928a95e7c9ce80b Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 17 Oct 2023 17:18:14 +0300 Subject: [PATCH] tst_qdbusmarshall: disambiguate unittest data tag names Drive-by change, initialize a QList with std::initializer list instead of old style operator()<<. Change-Id: If5745a4554772661df438e757518f8cb55a8a55c Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne --- .../dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 2d12bba356..9df9f78248 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -413,7 +413,7 @@ void tst_QDBusMarshall::sendArrayOfArrays_data() QTest::newRow("emptyvariantlist") << QVariant::fromValue(variants) << "aav" << "[Argument: aav {}]"; variants << QVariantList(); - QTest::newRow("emptyvariantlist") << QVariant::fromValue(variants) << "aav" + QTest::newRow("variantlist-empty-variantlist-element") << QVariant::fromValue(variants) << "aav" << "[Argument: aav {[Argument: av {}]}]"; variants << (QVariantList() << QString("Hello") << QByteArray("World")) << (QVariantList() << 42 << -43.0 << 44U << Q_INT64_C(-45)) @@ -948,12 +948,12 @@ void tst_QDBusMarshall::sendCallErrors_data() << "org.qtproject.QtDBus.Error.InvalidMember" << "Invalid method name: this isn't valid" << ""; - QTest::newRow("invalid-variant1") << serviceName << objectPath << interfaceName << "ping" + QTest::newRow("invalid-variant") << serviceName << objectPath << interfaceName << "ping" << (QVariantList() << QVariant()) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Invalid QVariant passed in arguments" << "QDBusMarshaller: cannot add an invalid QVariant"; - QTest::newRow("invalid-variant1") << serviceName << objectPath << interfaceName << "ping" + QTest::newRow("invalid-qdbusvariant") << serviceName << objectPath << interfaceName << "ping" << (QVariantList() << QVariant::fromValue(QDBusVariant())) << "org.freedesktop.DBus.Error.Failed" << "Marshalling failed: Invalid QVariant passed in arguments" @@ -1303,22 +1303,23 @@ void tst_QDBusMarshall::demarshallStrings_data() // All primitive types demarshall to null string types typedef QPair ValSigPair; - const QList nullStringTypes - = QList() - << ValSigPair(QVariant::fromValue(QString()), 's') - << ValSigPair(QVariant::fromValue(QDBusObjectPath()), 'o') - << ValSigPair(QVariant::fromValue(QDBusSignature()), 'g'); - for (const ValSigPair &valSigPair : nullStringTypes) { - QTest::newRow("bool(false)") << QVariant(false) << valSigPair.second << valSigPair.first; - QTest::newRow("bool(true)") << QVariant(true) << valSigPair.second << valSigPair.first; - QTest::newRow("byte") << QVariant::fromValue(uchar(1)) << valSigPair.second << valSigPair.first; - QTest::newRow("int16") << QVariant::fromValue(short(2)) << valSigPair.second << valSigPair.first; - QTest::newRow("uint16") << QVariant::fromValue(ushort(3)) << valSigPair.second << valSigPair.first; - QTest::newRow("int") << QVariant(1) << valSigPair.second << valSigPair.first; - QTest::newRow("uint") << QVariant(2U) << valSigPair.second << valSigPair.first; - QTest::newRow("int64") << QVariant(Q_INT64_C(3)) << valSigPair.second << valSigPair.first; - QTest::newRow("uint64") << QVariant(Q_UINT64_C(4)) << valSigPair.second << valSigPair.first; - QTest::newRow("double") << QVariant(42.5) << valSigPair.second << valSigPair.first; + const QList nullStringTypes = { + ValSigPair(QVariant::fromValue(QString()), 's'), + ValSigPair(QVariant::fromValue(QDBusObjectPath()), 'o'), + ValSigPair(QVariant::fromValue(QDBusSignature()), 'g') + }; + for (const auto &[v, charSymbol] : nullStringTypes) { + const char *name = v.typeName(); + QTest::addRow("bool(false)-%s", name) << QVariant(false) << charSymbol << v; + QTest::addRow("bool(true)-%s", name) << QVariant(true) << charSymbol << v; + QTest::addRow("byte-%s", name) << QVariant::fromValue(uchar(1)) << charSymbol << v; + QTest::addRow("int16-%s", name) << QVariant::fromValue(short(2)) << charSymbol << v; + QTest::addRow("uint16-%s", name) << QVariant::fromValue(ushort(3)) << charSymbol << v; + QTest::addRow("int-%s", name) << QVariant(1) << charSymbol << v; + QTest::addRow("uint-%s", name) << QVariant(2U) << charSymbol << v; + QTest::addRow("int64-%s", name) << QVariant(Q_INT64_C(3)) << charSymbol << v; + QTest::addRow("uint64-%s", name) << QVariant(Q_UINT64_C(4)) << charSymbol << v; + QTest::addRow("double-%s", name) << QVariant(42.5) << charSymbol << v; } // String types should demarshall to each other. This is a regression test