-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
4.5.1
-
None
Summary should be pretty self explanatory I guess.
The problem is that when the type is declared, the object is initialized. The == operator should take isNull() into account.
here's a testcase that illustrates the problem:
#include <QtTest/QtTest> #include <QVariant> class Test : public QObject{ Q_OBJECT private slots: void testNullVariant_data(){ QTest::addColumn<int>("type"); QTest::newRow("double") << int(QVariant::Double); QTest::newRow("int") << int(QVariant::Int); QTest::newRow("bool") << int(QVariant::Bool); QTest::newRow("uint") << int(QVariant::UInt); QTest::newRow("ulonglong") << int(QVariant::ULongLong); QTest::newRow("longlong") << int(QVariant::LongLong); } void testNullVariant(){ QVariant v1(0); QFETCH(int, type); QVariant v2 = QVariant((QVariant::Type)type); QVERIFY(!v1.isNull()); QVERIFY(v2.isNull()); QEXPECT_FAIL("", "are not equal", Abort); QCOMPARE(v1,v2); } void testEmptyStringVariant(){ QVariant v1(""); QVariant v2 = QVariant(QVariant::String); QVERIFY(!v1.isNull()); QVERIFY(v2.isNull()); QEXPECT_FAIL("", "are not equal", Abort); QCOMPARE(v1,v2); } }; QTEST_MAIN(Test) #include "test.moc"
NB: Since this could break compatibility behaviour, it might not be changed in a very near future.