QTest::addColumn<QObject>
-
I am getting the error:
In file included from /opt/Qt/5.3/gcc_64/include/QtCore/qobject.h:56:0,
from /opt/Qt/5.3/gcc_64/include/QtCore/QObject:1,
from ../../../TecTracker/Core/tests/testdataaccess.hpp:4,
from ../../../TecTracker/Core/tests/testdataaccess.cpp:1:
/opt/Qt/5.3/gcc_64/include/QtCore/qmetatype.h: In instantiation of 'int qMetaTypeId() [with T = QObject]':
/opt/Qt/5.3/gcc_64/include/QtTest/qtestcase.h:282:42: required from 'void QTest::addColumn(const char*, T*) [with T = QObject]'
../../../TecTracker/Core/tests/testdataaccess.cpp:16:38: required from here
/opt/Qt/5.3/gcc_64/include/QtCore/qmetatype.h:1615:44: error: invalid application of 'sizeof' to incomplete type 'QStaticAssertFailure<false>'
Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
^This is a test case for a class to connect to the database.
the complete unity test code, below
@#ifndef TESTDATAACCESS_HPP
#define TESTDATAACCESS_HPP#include <QObject>
#include<QtTest/QTest>class TestDataAccess : public QObject
{Q_OBJECT
public:
explicit TestDataAccess(QObject *parent = 0);private Q_SLOTS:
void testInstace();
void testConection();
void testConection_data();
};#endif // TESTDATAACCESS_HPP
@@#include "testdataaccess.hpp"
#include "dataaccess.hpp"TestDataAccess::TestDataAccess(QObject *parent) : QObject(parent)
{
}void TestDataAccess::testInstace()
{
QVERIFY(DataAccess::instance());
}void TestDataAccess::testConection_data()
{
QTest::addColumn<QObject>("parente");
QTest::addColumn<bool>("banco");QTest::newRow("Normal") << this << true;
QTest::newRow("Sem parente") << 0 << true;
}void TestDataAccess::testConection()
{
QSqlDatabase *objdata;QFETCH(QObject*, parente);
QFETCH(bool, banco);
QCOMPARE(DataAccess::instance()->conection(objdata, parente)->open(), banco);delete objdata;
}
@ -
-
It seems you are not linking to the test module at least