From 3bcc60fe180a27a63ccc7a4b0635454316e37748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 24 Oct 2016 21:13:30 +0200 Subject: converterTest: add tests for toQVariantFromVariantString --- tests/client/convertertest.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp index 10c3b4c..fe72181 100644 --- a/tests/client/convertertest.cpp +++ b/tests/client/convertertest.cpp @@ -251,6 +251,32 @@ private Q_SLOTS: QVERIFY(compare(value, (QVariant::Type) expectedType)); } + void testConvertToQVariantFromString_data() + { + QTest::addColumn("value"); + QTest::addColumn("expectedType"); + + QTest::newRow("Boolean") << "true" << (unsigned) QVariant::Bool; + QTest::newRow("Byte") << "byte 0xFF" << (unsigned) QMetaType::UChar; + QTest::newRow("Int16") << "int16 65" << (unsigned) QMetaType::Short; + QTest::newRow("UInt16") << "uint16 65" << (unsigned) QMetaType::UShort; + QTest::newRow("Int32") << "int32 65" << (unsigned) QVariant::Int; + QTest::newRow("UInt32") << "uint32 65" << (unsigned) QVariant::UInt; + QTest::newRow("Int64") << "int64 65" << (unsigned) QVariant::LongLong; + QTest::newRow("UInt64") << "uint64 65" << (unsigned) QVariant::ULongLong; + QTest::newRow("Double") << "double 65" << (unsigned) QVariant::Double; + QTest::newRow("String") << "string '65'" << (unsigned) QVariant::String; + QTest::newRow("String simple") << "\"65\"" << (unsigned) QVariant::String; + } + + void testConvertToQVariantFromString() + { + QFETCH(QString, value); + QFETCH(unsigned, expectedType); + + QCOMPARE(Converter::toQVariantFromVariantString(value).type(), (QVariant::Type) expectedType); + } + }; QTEST_MAIN(ConverterTest) -- cgit v1.2.3