aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2016-10-24 21:13:30 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2016-10-24 21:13:30 +0200
commit3bcc60fe180a27a63ccc7a4b0635454316e37748 (patch)
tree64c510036c4e30657daefb50aaa1f73ddf001ac8 /tests
parentabc65a4bd4bf3957b47367da58783265773b5bb4 (diff)
downloadqmenumodel-3bcc60fe180a27a63ccc7a4b0635454316e37748.tar.gz
qmenumodel-3bcc60fe180a27a63ccc7a4b0635454316e37748.tar.bz2
qmenumodel-3bcc60fe180a27a63ccc7a4b0635454316e37748.zip
converterTest: add tests for toQVariantFromVariantString
Diffstat (limited to 'tests')
-rw-r--r--tests/client/convertertest.cpp26
1 files changed, 26 insertions, 0 deletions
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<QString>("value");
+ QTest::addColumn<unsigned>("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)