diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-10-22 18:40:29 +0200 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-10-22 18:40:29 +0200 |
commit | 00ddb5fcb1b738480e161a47a319fd6b3470b2c9 (patch) | |
tree | d00701485b44665bd7d1d2176ad3d6a4e85d853b | |
parent | 81e73a200ead6b9eee4d86a0a0484c184b1ee758 (diff) | |
download | qmenumodel-00ddb5fcb1b738480e161a47a319fd6b3470b2c9.tar.gz qmenumodel-00ddb5fcb1b738480e161a47a319fd6b3470b2c9.tar.bz2 qmenumodel-00ddb5fcb1b738480e161a47a319fd6b3470b2c9.zip |
convertertest: repeat tests using test data
-rw-r--r-- | tests/client/convertertest.cpp | 107 |
1 files changed, 26 insertions, 81 deletions
diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 1f930df..05656ed 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -68,88 +68,33 @@ private Q_SLOTS: * Test converter QVariant to GVariant */ - void testBooleanToGVariant() + void testConvertToGVariant_data() { - // Boolean - QVERIFY(compare(QVariant(true), G_VARIANT_TYPE_BOOLEAN)); - } - - void testByteToGVariant() - { - // Byte - QVERIFY(compare(QVariant::fromValue<uchar>(42), G_VARIANT_TYPE_BYTE)); - } - - void testInt16ToGVariant() - { - // Int16 - QVERIFY(compare(QVariant::fromValue<short>(-42), G_VARIANT_TYPE_INT16)); - } - - void testUInt16ToGVariant() - { - // UInt16 - QVERIFY(compare(QVariant::fromValue<ushort>(-42), G_VARIANT_TYPE_UINT16)); - } - - void testInt32ToGVariant() - { - // Int32 - QVERIFY(compare(QVariant(-42), G_VARIANT_TYPE_INT32)); - } - - void testUInt32ToGVariant() - { - // UInt32 - QVERIFY(compare(QVariant((uint)42), G_VARIANT_TYPE_UINT32)); - } - - void testInt64ToGVariant() - { - // Int64 - QVERIFY(compare(QVariant::fromValue<long>(-42), G_VARIANT_TYPE_INT64)); - } - - void testUInt64ToGVariant() - { - // UInt64 - QVERIFY(compare(QVariant::fromValue<ulong>(42), G_VARIANT_TYPE_UINT64)); - } - - void testQlongLongToGVariant() - { - // Int64 - QVERIFY(compare(QVariant::fromValue<qlonglong>(-42), G_VARIANT_TYPE_INT64)); - } - - void testUQlongLongToGVariant() - { - // UInt64 - QVERIFY(compare(QVariant::fromValue<qulonglong>(42), G_VARIANT_TYPE_UINT64)); - } - - void testDoubleToGVariant() - { - // Double - QVERIFY(compare(QVariant((double)42.42), G_VARIANT_TYPE_DOUBLE)); - } - - void testStringToGVariant() - { - // String - QVERIFY(compare(QVariant(QString("42")), G_VARIANT_TYPE_STRING)); - } - - void testByteArrayToGVariant() + QTest::addColumn<QVariant>("value"); + QTest::addColumn<QString>("expectedType"); + + QTest::newRow("Boolean") << QVariant(true) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_BOOLEAN); + QTest::newRow("Byte") << QVariant::fromValue<uchar>(42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_BYTE); + QTest::newRow("Int16") << QVariant::fromValue<short>(-42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_INT16); + QTest::newRow("UInt16") << QVariant::fromValue<ushort>(-42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_UINT16); + QTest::newRow("Int32") << QVariant(-42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_INT32); + QTest::newRow("UInt32") << QVariant((uint)42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_UINT32); + QTest::newRow("Int64") << QVariant::fromValue<long>(-42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_INT64); + QTest::newRow("UInt64") << QVariant::fromValue<ulong>(42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_UINT64); + QTest::newRow("Int64") << QVariant::fromValue<qlonglong>(-42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_INT64); + QTest::newRow("UInt64") << QVariant::fromValue<qulonglong>(42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_UINT64); + QTest::newRow("Double") << QVariant((double)42.42) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_DOUBLE); + QTest::newRow("String") << QVariant(QString("42")) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_STRING); + QTest::newRow("ByteArray") << QVariant(QByteArray("42")) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_BYTESTRING); + QTest::newRow("Map") << QVariant(QVariantMap()) << reinterpret_cast<const gchar*>(G_VARIANT_TYPE_VARDICT); + } + + void testConvertToGVariant() { - // ByteArray - QVERIFY(compare(QVariant(QByteArray("42")), G_VARIANT_TYPE_BYTESTRING)); - } + QFETCH(QVariant, value); + QFETCH(QString, expectedType); - void testMapToGVariant() - { - // Map - QVERIFY(compare(QVariantMap(), G_VARIANT_TYPE_VARDICT)); + QVERIFY(compare(value, g_variant_type_new(expectedType.toUtf8().data()))); } void testTupleConversion() @@ -179,7 +124,7 @@ private Q_SLOTS: g_variant_unref(gTuple); } - void testSchemaConvert_data() + void testConvertToGVariantWithSchema_data() { QTest::addColumn<QVariant>("value"); QTest::addColumn<QString>("schema"); @@ -224,7 +169,7 @@ private Q_SLOTS: QTest::newRow("map") << QVariant(map) << "a{sv}"; } - void testSchemaConvert() + void testConvertToGVariantWithSchema() { QFETCH(QVariant, value); QFETCH(QString, schema); |