summaryrefslogtreecommitdiffstats
path: root/tests/auto/qvariant
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-03-03 10:07:26 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-03-03 10:48:16 (GMT)
commit7a6f492a6dcf9140eda309dcdff6e0f8d321df19 (patch)
treecde3260385069df41659cac82e6228ab956c2eee /tests/auto/qvariant
parent24cf789b68f21b2d1ea31580e55c91a2cae25a12 (diff)
downloadQt-7a6f492a6dcf9140eda309dcdff6e0f8d321df19.zip
Qt-7a6f492a6dcf9140eda309dcdff6e0f8d321df19.tar.gz
Qt-7a6f492a6dcf9140eda309dcdff6e0f8d321df19.tar.bz2
Fix QVariant autotest
After 03daf059647c0a0222e8774b0a083f58c8e64934, typedef of int are just aliases to int, and therefor we need to use a real custom type for the test now Reviewed-by: Thierry
Diffstat (limited to 'tests/auto/qvariant')
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index a316dda..1a4182f 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -2518,15 +2518,23 @@ void tst_QVariant::variant_to()
QCOMPARE(qVariantFromValue(0.25f).toDouble(), 0.25);
}
+struct Blah { int i; };
+
+QDataStream& operator>>(QDataStream& s, Blah& c)
+{ return (s >> c.i); }
+
+QDataStream& operator<<(QDataStream& s, const Blah& c)
+{ return (s << c.i); }
+
void tst_QVariant::saveLoadCustomTypes()
{
QByteArray data;
- int i = 42;
- int tp = qRegisterMetaType<int>("Blah");
+ Blah i = { 42 };
+ int tp = qRegisterMetaType<Blah>("Blah");
QVariant v = QVariant(tp, &i);
- qRegisterMetaTypeStreamOperators<int>("Blah");
+ qRegisterMetaTypeStreamOperators<Blah>("Blah");
QCOMPARE(v.userType(), tp);
QVERIFY(v.type() == QVariant::UserType);