From 894fbb91c8fa95e696fc45364f8ffda76417427e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 12:06:35 +0200 Subject: convertertest: use better variant map test --- tests/client/convertertest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 6f0f949..fe70840 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -149,7 +149,7 @@ private Q_SLOTS: void testMapToGVariant() { // Map - QVERIFY(compare(QVariantMap(), G_VARIANT_TYPE_VARDICT)); + QVERIFY(compare(QVariantMap({{"fooBar", 0xdeadbeef}}), G_VARIANT_TYPE_VARDICT)); } void testTupleConversion() -- cgit v1.2.3 From 3edd18dc46ebb95962f17de0c77ee72f469fd917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 12:40:19 +0200 Subject: ConverterTest: add tests for toQVariant --- tests/client/convertertest.cpp | 85 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 3 deletions(-) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index fe70840..a6a82de 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -39,12 +39,29 @@ private: result = g_variant_type_equal(g_variant_get_type(gv), type); if (!result) { qWarning() << "types are different: QVariant:" << qv.typeName() - << "Result:" << (const char*) g_variant_get_type(gv) - << "Expected:"<< (const char*) type; + << "Result:" << g_variant_type_peek_string (g_variant_get_type(gv)) + << "Expected:"<< g_variant_type_peek_string (type); + } + g_variant_unref(gv); + return result; + } + bool compare(GVariant *gv, const QVariant::Type type) + { + g_variant_ref_sink(gv); + const QVariant& qv = Converter::toQVariant(gv); + bool result = (qv.type() == type); + if (!result) { + qWarning() << "types are different: GVariant:" << g_variant_type_peek_string (g_variant_get_type(gv)) + << "Result:" << qv.type() + << "Expected:"<< type; } g_variant_unref(gv); return result; } + bool compare(GVariant *gv, const QMetaType::Type type) + { + return compare(gv, (QVariant::Type) type); + } bool compareWithSchema(const QVariant &qv, const QString strType) { GVariantType* expected_type; @@ -89,7 +106,7 @@ private Q_SLOTS: void testUInt16ToGVariant() { // UInt16 - QVERIFY(compare(QVariant::fromValue(-42), G_VARIANT_TYPE_UINT16)); + QVERIFY(compare(QVariant::fromValue(42), G_VARIANT_TYPE_UINT16)); } void testInt32ToGVariant() @@ -152,6 +169,68 @@ private Q_SLOTS: QVERIFY(compare(QVariantMap({{"fooBar", 0xdeadbeef}}), G_VARIANT_TYPE_VARDICT)); } + // LIST CHECK! + + void testBooleanToQVariant() + { + // Boolean + QVERIFY(compare(g_variant_new_boolean(TRUE), QVariant::Bool)); + } + + void testByteToQVariant() + { + // Byte + QVERIFY(compare(g_variant_new_byte(53), QMetaType::UChar)); + } + + void testInt16ToQVariant() + { + // Int16 + QVERIFY(compare(g_variant_new_int16(-53), QMetaType::Short)); + } + + void testUInt16ToQVariant() + { + // UInt16 + QVERIFY(compare(g_variant_new_uint16(53), QMetaType::UShort)); + } + + void testInt32ToQVariant() + { + // Int32 + QVERIFY(compare(g_variant_new_int32(-53), QVariant::Int)); + } + + void testUInt32ToQVariant() + { + // UInt32 + QVERIFY(compare(g_variant_new_uint32(53), QVariant::UInt)); + } + + void testInt64ToQVariant() + { + // Int64 + QVERIFY(compare(g_variant_new_int64(-53), QVariant::LongLong)); + } + + void testUInt64ToQVariant() + { + // UInt64 + QVERIFY(compare(g_variant_new_uint64(53), QVariant::ULongLong)); + } + + void testDoubleToQVariant() + { + // Double + QVERIFY(compare(g_variant_new_double(53.53), QVariant::Double)); + } + + void testStringToQVariant() + { + // String + QVERIFY(compare(g_variant_new_string("53"), QVariant::String)); + } + void testTupleConversion() { QVariantList qTuple; -- cgit v1.2.3 From e87701e0f2d5f3b7dd291c7b8c62e407b5abf4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 12:53:27 +0200 Subject: Converter: add bytestring support --- tests/client/convertertest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index a6a82de..e61caa0 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -169,8 +169,6 @@ private Q_SLOTS: QVERIFY(compare(QVariantMap({{"fooBar", 0xdeadbeef}}), G_VARIANT_TYPE_VARDICT)); } - // LIST CHECK! - void testBooleanToQVariant() { // Boolean @@ -231,6 +229,12 @@ private Q_SLOTS: QVERIFY(compare(g_variant_new_string("53"), QVariant::String)); } + void testByteArrayToQVariant() + { + // ByteArray + QVERIFY(compare(g_variant_new_bytestring("53"), QVariant::ByteArray)); + } + void testTupleConversion() { QVariantList qTuple; -- cgit v1.2.3 From c42bc210a32f06b2850fbe010be9356d477330b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 15:39:20 +0200 Subject: Converter: add support for ByteArrayList --- tests/client/convertertest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index e61caa0..933ed2f 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -163,6 +163,14 @@ private Q_SLOTS: QVERIFY(compare(QVariant(QByteArray("42")), G_VARIANT_TYPE_BYTESTRING)); } + void testByteArrayListToGVariant() + { + // ByteArrayList + QVariant result; + result.setValue(QByteArrayList({"42", "53"})); + QVERIFY(compare(result, G_VARIANT_TYPE_BYTESTRING_ARRAY)); + } + void testMapToGVariant() { // Map @@ -235,6 +243,13 @@ private Q_SLOTS: QVERIFY(compare(g_variant_new_bytestring("53"), QVariant::ByteArray)); } + void testByteArrayListToQVariant() + { + // ByteArrayList + const gchar * byteArray[] = {"42", "53", NULL}; + QVERIFY(compare(g_variant_new_bytestring_array(byteArray, -1), QMetaType::QByteArrayList)); + } + void testTupleConversion() { QVariantList qTuple; -- cgit v1.2.3 From d3899e64d6c24337d1547854da7e3cb9499d9d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 16:09:51 +0200 Subject: convertertest: add conversion from map to qvariant check --- tests/client/convertertest.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 933ed2f..89e1de4 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -246,10 +246,19 @@ private Q_SLOTS: void testByteArrayListToQVariant() { // ByteArrayList - const gchar * byteArray[] = {"42", "53", NULL}; + const gchar *byteArray[] = {"42", "53", NULL}; QVERIFY(compare(g_variant_new_bytestring_array(byteArray, -1), QMetaType::QByteArrayList)); } + void testMapToQVariant() + { + // Map + GVariantBuilder *b = g_variant_builder_new(G_VARIANT_TYPE_VARDICT); + g_variant_builder_add(b, "{sv}", "Foo", g_variant_new_int32(53)); + QVERIFY(compare(g_variant_builder_end(b), QVariant::Map)); + g_variant_builder_unref(b); + } + void testTupleConversion() { QVariantList qTuple; -- cgit v1.2.3 From d8aa8818169b758899ede0ec7932c6fe6f3ef4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 16:15:55 +0200 Subject: ConverterTest: add QVariantList conversion test --- tests/client/convertertest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 89e1de4..32d6091 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -177,6 +177,12 @@ private Q_SLOTS: QVERIFY(compare(QVariantMap({{"fooBar", 0xdeadbeef}}), G_VARIANT_TYPE_VARDICT)); } + void testListToGVariant() + { + // List + QVERIFY(compare(QVariantList({"42", 53}), G_VARIANT_TYPE("(si)"))); + } + void testBooleanToQVariant() { // Boolean -- cgit v1.2.3 From 3def677b32e7cf1916de2cdf6be01a7a0cc43d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Oct 2016 17:27:13 +0200 Subject: Converter: use builders and c++ facilities for schema conversions --- tests/client/convertertest.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 32d6091..5a9367f 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -295,38 +295,38 @@ private Q_SLOTS: void testSchemaConvert() { // convert to integer - compareWithSchema(QVariant::fromValue(1), "i"); - compareWithSchema(QVariant::fromValue(1.1), "i"); + QVERIFY(compareWithSchema(QVariant::fromValue(1), "i")); + QVERIFY(compareWithSchema(QVariant::fromValue(1.1), "i")); // convert to integer - compareWithSchema(QVariant::fromValue(true), "b"); - compareWithSchema(QVariant::fromValue(1), "b"); + QVERIFY(compareWithSchema(QVariant::fromValue(true), "b")); + QVERIFY(compareWithSchema(QVariant::fromValue(1), "b")); // convert to double - compareWithSchema(QVariant::fromValue(1.0), "d"); - compareWithSchema(QVariant::fromValue(1), "d"); + QVERIFY(compareWithSchema(QVariant::fromValue(1.0), "d")); + QVERIFY(compareWithSchema(QVariant::fromValue(1), "d")); // convert to string - compareWithSchema(QVariant::fromValue(1), "s"); - compareWithSchema(QVariant::fromValue(1.1), "s"); + QVERIFY(compareWithSchema(QVariant::fromValue(1), "s")); + QVERIFY(compareWithSchema(QVariant::fromValue(1.1), "s")); // convert to tuple - compareWithSchema(QVariantList() << QVariant::fromValue(true) << QVariant::fromValue(1) << QVariant::fromValue(1) << QVariant::fromValue("test1"), "(bdis)"); + QVERIFY(compareWithSchema(QVariantList() << QVariant::fromValue(true) << QVariant::fromValue(1) << QVariant::fromValue(1) << QVariant::fromValue("test1"), "(bdis)")); // convert to array - compareWithSchema(QVariantList() << QVariant::fromValue(1) << QVariant::fromValue(1), "ad"); - compareWithSchema(QVariantList() << QVariant::fromValue("test1") << QVariant::fromValue("test2"), "as"); + QVERIFY(compareWithSchema(QVariantList() << QVariant::fromValue(1) << QVariant::fromValue(1), "ad")); + QVERIFY(compareWithSchema(QVariantList() << QVariant::fromValue("test1") << QVariant::fromValue("test2"), "as")); // convert to array of tuple QVariantList si1(QVariantList() << QVariant::fromValue("test1") << QVariant::fromValue(1)); QVariantList si2(QVariantList() << QVariant::fromValue("test1") << QVariant::fromValue(1)); - compareWithSchema(QVariantList() << QVariant::fromValue(si1) << QVariant::fromValue(si2), "a(sd)"); + QVERIFY(compareWithSchema(QVariantList() << QVariant::fromValue(si1) << QVariant::fromValue(si2), "a(sd)")); // convert to vardict QVariantMap map; map["test1"] = QVariant::fromValue(1); map["test2"] = QVariant::fromValue(1); - compareWithSchema(map, "a{sv}"); + QVERIFY(compareWithSchema(map, "a{sv}")); } }; -- cgit v1.2.3 From 6d2076c889b4d914672e2bbfd1c218252b9ed1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 16:50:59 +0200 Subject: Converter: add support to String Arrays --- tests/client/convertertest.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 45b104e..3bd1f74 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -131,6 +131,7 @@ private Q_SLOTS: QTest::newRow("UInt64") << QVariant::fromValue(42) << QGVariantType(G_VARIANT_TYPE_UINT64); QTest::newRow("Double") << QVariant((double)42.42) << QGVariantType(G_VARIANT_TYPE_DOUBLE); QTest::newRow("String") << QVariant(QString("42")) << QGVariantType(G_VARIANT_TYPE_STRING); + QTest::newRow("String List") << QVariant(QStringList({"42", "42"})) << QGVariantType(G_VARIANT_TYPE_STRING_ARRAY); QTest::newRow("ByteArray") << QVariant(QByteArray("42")) << QGVariantType(G_VARIANT_TYPE_BYTESTRING); QTest::newRow("Map") << QVariant(QVariantMap()) << QGVariantType(G_VARIANT_TYPE_VARDICT); QTest::newRow("Map Filled") << QVariant(QVariantMap({{"fooBar", 0xdeadbeef}})) << QGVariantType(G_VARIANT_TYPE_VARDICT); @@ -264,6 +265,7 @@ private Q_SLOTS: const gchar *byteArray[] = {"42", "53", NULL}; QTest::newRow("ByteArrayList") << QGVariant(g_variant_new_bytestring_array(byteArray, -1)) << (unsigned) QMetaType::QByteArrayList; + QTest::newRow("String List") << QGVariant(g_variant_new_strv(byteArray, -1)) << (unsigned) QVariant::StringList; } void testConvertToQVariant() @@ -290,6 +292,7 @@ private Q_SLOTS: QTest::newRow("Double") << "double 65" << (unsigned) QVariant::Double; QTest::newRow("String") << "string '65'" << (unsigned) QVariant::String; QTest::newRow("String simple") << "\"65\"" << (unsigned) QVariant::String; + QTest::newRow("String List") << "['foo', 'bar']" << (unsigned) QVariant::StringList; QTest::newRow("Byte string") << "b'fooo'" << (unsigned) QVariant::ByteArray; QTest::newRow("Map") << "{'foo': <65>}" << (unsigned) QVariant::Map; QTest::newRow("List") << "[65, 66]" << (unsigned) QVariant::List; -- cgit v1.2.3 From a4c1bb65572e613df99badc821c79a79764986f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 16:58:28 +0200 Subject: converterTest: simplify metatype definitions --- tests/client/convertertest.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 3bd1f74..9e13ccb 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -28,13 +28,11 @@ extern "C" { #include #include -class QGVariantType : public QObject +class QGVariantType { - Q_OBJECT public: QGVariantType() : type(NULL) {} QGVariantType(const GVariantType *gvtype) : type(gvtype) {} - QGVariantType(const QGVariantType &other) : type(other.type) {} const GVariantType *getType() const { return type; } operator const GVariantType*() const { return type; } @@ -43,14 +41,13 @@ private: }; Q_DECLARE_METATYPE(QGVariantType); -class QGVariant : public QObject +class QGVariant { - Q_OBJECT public: QGVariant() : variant(NULL) {} ~QGVariant() { if (variant) g_variant_unref(variant); } QGVariant(GVariant *gv) : variant(g_variant_ref_sink(gv)) {} - QGVariant(const QGVariant &other) : variant(g_variant_ref_sink(other.variant)) {} + QGVariant(const QGVariant &other) : QGVariant(other.variant) {} GVariant *gvariant() const { return variant; } operator GVariant*() const { return variant; } -- cgit v1.2.3 From eb6e5b591ec3972dad11656fff6bfa0597483c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 20:55:34 +0200 Subject: converter: verify integer type conversions --- tests/client/convertertest.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 9e13ccb..f1fd48e 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -180,9 +180,17 @@ private Q_SLOTS: QTest::addColumn("value"); QTest::addColumn("schema"); + // convert to byte + QTest::newRow("byte") << QVariant::fromValue(1) << "y"; + // convert to integer QTest::newRow("integer") << QVariant::fromValue(1) << "i"; QTest::newRow("integer from double") << QVariant::fromValue(1.1) << "i"; + QTest::newRow("int16") << QVariant::fromValue(-1) << "n"; + QTest::newRow("uint16") << QVariant::fromValue(1) << "q"; + QTest::newRow("uint32") << QVariant::fromValue(1) << "u"; + QTest::newRow("int64") << QVariant::fromValue(1) << "x"; + QTest::newRow("uint64") << QVariant::fromValue(1) << "t"; // convert to bool QTest::newRow("bool") << QVariant::fromValue(true) << "b"; -- cgit v1.2.3 From d56d0baefd53a8c7f3a9cd10fcaaeef1826e7d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Oct 2016 20:56:40 +0200 Subject: converter: return a variant when the schema is a variant --- tests/client/convertertest.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index f1fd48e..5492a02 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -192,6 +192,11 @@ private Q_SLOTS: QTest::newRow("int64") << QVariant::fromValue(1) << "x"; QTest::newRow("uint64") << QVariant::fromValue(1) << "t"; + // convert to variant + QTest::newRow("variant from int") << QVariant::fromValue(1) << "v"; + QTest::newRow("variant from double") << QVariant::fromValue(1.1) << "v"; + QTest::newRow("variant from string") << QVariant::fromValue("string") << "v"; + // convert to bool QTest::newRow("bool") << QVariant::fromValue(true) << "b"; QTest::newRow("bool from int") << QVariant::fromValue(1) << "b"; -- cgit v1.2.3 From e1ee47eaef71ffa0519843c5022d1d239512b866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 26 Oct 2016 14:28:59 +0200 Subject: converterTest: add conversion to GVariant and back to verify content is correct --- tests/client/convertertest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 5492a02..bc10f10 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -148,6 +148,24 @@ private Q_SLOTS: QVERIFY(compare(value, expectedType)); } + void testConvertToGVariantAndBack_data() + { + testConvertToGVariant_data(); + } + + void testConvertToGVariantAndBack() + { + QFETCH(QVariant, value); + QFETCH(QGVariantType, expectedType); + + GVariant *gv = Converter::toGVariant(value); + QVERIFY(gv != NULL); + + QCOMPARE(Converter::toQVariant(gv), value); + + g_variant_unref(gv); + } + void testTupleConversion() { QVariantList qTuple; -- cgit v1.2.3 From 352a7702cca19608712423e6ca2c91f491e79013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 26 Oct 2016 14:58:18 +0200 Subject: converterTest: add content conversions back and further from gvariant --- tests/client/convertertest.cpp | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'tests/client/convertertest.cpp') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index bc10f10..43127a7 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -156,7 +156,6 @@ private Q_SLOTS: void testConvertToGVariantAndBack() { QFETCH(QVariant, value); - QFETCH(QGVariantType, expectedType); GVariant *gv = Converter::toGVariant(value); QVERIFY(gv != NULL); @@ -291,6 +290,8 @@ private Q_SLOTS: QTest::newRow("List") << QGVariant(g_variant_new("ai", builder)) << (unsigned) QVariant::List; g_variant_builder_unref(builder); + QTest::newRow("Tuple") << QGVariant(g_variant_new("(i)", 53)) << (unsigned) QVariant::List; + const gchar *byteArray[] = {"42", "53", NULL}; QTest::newRow("ByteArrayList") << QGVariant(g_variant_new_bytestring_array(byteArray, -1)) << (unsigned) QMetaType::QByteArrayList; QTest::newRow("String List") << QGVariant(g_variant_new_strv(byteArray, -1)) << (unsigned) QVariant::StringList; @@ -304,6 +305,47 @@ private Q_SLOTS: QVERIFY(compare(value, (QVariant::Type) expectedType)); } + void testConvertToQVariantAndBack_data() + { + testConvertToQVariant_data(); + } + + void testConvertToQVariantAndBack() + { + QFETCH(QGVariant, value); + + QVariant qv = Converter::toQVariant(value); + QVERIFY(qv.isValid()); + + GVariant *gv = Converter::toGVariant(qv); + gboolean equals = g_variant_equal(value, gv); + + if (!equals && qv.type() == QVariant::List) { + QVERIFY(g_variant_type_is_array(g_variant_get_type(value))); + QVERIFY(g_variant_type_is_tuple(g_variant_get_type(gv))); + + gsize vsize = g_variant_n_children(value); + QCOMPARE(vsize, g_variant_n_children(gv)); + + for (gsize i = 0; i < vsize; ++i) { + equals = g_variant_equal(g_variant_get_child_value(value, i), g_variant_get_child_value(gv, i)); + if (!equals) + break; + } + } + + if (!equals) { + gchar *vs = g_variant_print(value, TRUE); + gchar *gvs = g_variant_print(gv, TRUE); + qWarning() << "Values do not match. Old" << vs << "converted" << gvs; + g_free(vs); + g_free(gvs); + } + + g_variant_unref(gv); + QVERIFY(equals != FALSE); + } + void testConvertToQVariantFromString_data() { QTest::addColumn("value"); -- cgit v1.2.3