Add new test cases to tst_QMetaType.

Change-Id: I405ab5df9d9de3a0a0a71276b172a27ee01392e3
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
bb10
Jędrzej Nowacki 2012-03-08 15:49:55 +01:00 committed by Qt by Nokia
parent 78e0ab3342
commit 5e497111db
1 changed files with 14 additions and 6 deletions

View File

@ -629,18 +629,26 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_COPY_FUNCTION)
void tst_QMetaType::sizeOf_data()
{
QTest::addColumn<QMetaType::Type>("type");
QTest::addColumn<int>("size");
QTest::addColumn<size_t>("size");
#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
QTest::newRow(#RealType) << QMetaType::MetaTypeName << int(QTypeInfo<RealType>::sizeOf);
QTest::newRow(#RealType) << QMetaType::MetaTypeName << size_t(QTypeInfo<RealType>::sizeOf);
FOR_EACH_CORE_METATYPE(ADD_METATYPE_TEST_ROW)
#undef ADD_METATYPE_TEST_ROW
QTest::newRow("Whity<double>") << static_cast<QMetaType::Type>(::qMetaTypeId<Whity<double> >()) << sizeof(Whity<double>);
QTest::newRow("Whity<int>") << static_cast<QMetaType::Type>(::qMetaTypeId<Whity<int> >()) << sizeof(Whity<int>);
QTest::newRow("Testspace::Foo") << static_cast<QMetaType::Type>(::qMetaTypeId<TestSpace::Foo>()) << sizeof(TestSpace::Foo);
QTest::newRow("-1") << QMetaType::Type(-1) << size_t(0);
QTest::newRow("-124125534") << QMetaType::Type(-124125534) << size_t(0);
QTest::newRow("124125534") << QMetaType::Type(124125534) << size_t(0);
}
void tst_QMetaType::sizeOf()
{
QFETCH(QMetaType::Type, type);
QFETCH(int, size);
QCOMPARE(QMetaType::sizeOf(type), size);
QFETCH(size_t, size);
QCOMPARE(size_t(QMetaType::sizeOf(type)), size);
}
void tst_QMetaType::sizeOfStaticLess_data()
@ -651,8 +659,8 @@ void tst_QMetaType::sizeOfStaticLess_data()
void tst_QMetaType::sizeOfStaticLess()
{
QFETCH(QMetaType::Type, type);
QFETCH(int, size);
QCOMPARE(QMetaType(type).sizeOf(), size);
QFETCH(size_t, size);
QCOMPARE(size_t(QMetaType(type).sizeOf()), size);
}
struct CustomMovable {};