Qt-interest Archive, May 2007
a problem with QtTest
Message 1 in thread
Dear all,
I want to test a member function which reads data from a text file and
whose signature is :
static const QList<QPointF> load(QFile * file).
But I got the following incomplete output
********* Start testing of TestIOHelper *********
Config: Using QTest library 4.2.3, Qt 4.2.3
PASS : TestIOHelper::initTestCase()
Any idea what's going on?
BTW, I don't know what exactly Q_DECLARE_METATYPE does. Without it, I would
have got some strange compilation errors.
My test class is declared as follows:
Q_DECLARE_METATYPE(QList<QPointF>)
class TestIOHelper: public QObject
{
Q_OBJECT;
private slots:
void loadNode_data();
void loadNode();
};
void TestIOHelper::loadNode_data()
{
QTest::addColumn<QString>("fileName");
QTest::addColumn< QList<QPointF> >("result");
QList<QPointF> data = QList<QPointF>();
data.append( QPointF(1, 1) );
data.append( QPointF(2, 2.5) );
QTest::newRow("good1") << "good1.node" << data;
...
QTest::newRow("bad1") << "bad1.node" << data;
...
}
void TestIOHelper::loadNode()
{
QFETCH(QString, fileName);
QFETCH(QList<QPointF>, result);
QEXPECT_FAIL("bad1", "junk information detected", Continue);
QEXPECT_FAIL("bad2", "vertex number out of order", Continue);
QCOMPARE(IOHelper::loadNode(&(QFile(fileName))), result);
}
--
[ signature omitted ]