PDA

View Full Version : [QTest] adding class column and row



amreo
5th October 2015, 20:04
I've created a class named foo like:

class foo {
public:
int bar;
}

How can I add a column and row in QTest?

I've tried:


QTest::addColumn<foo>("f");
QTest::addColumn<foo*>("f");

//and
QTest::row("id1") << new foo();
QTest::row("id1") << foo();


but I've got a error like


/home/amreo/src/src-public/qt5/qt5/qtbase/include/QtCore/qglobal.h:703: error: invalid application of 'sizeof' to incomplete type 'QStaticAssertFailure<false>'
enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_resu lt, __COUNTER__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
^

anda_skoa
8th October 2015, 15:14
The test data mechanism stores data in QVariant.
You need to make your type known to the Qt meta type system



Q_DECLARE_METATYPE(foo);


Cheers,
_

amreo
8th October 2015, 18:18
When do I put it? In test class or in class?

anda_skoa
9th October 2015, 12:28
In the header of foo.

Cheers,
_