基本上我在这里遵循基本示例。我的.pro
文件包含QT += core network qtestlib
. [已解决] testlib代替错字 qtestlib
当我包含QVERIFY
时,它得到以下链接器错误:
testwaypointlist.obj:-1: error: LNK2019: unresolved external symbol "bool __cdecl
QTest::qVerify(bool,char const *,char const *,char const *,int)"
(?qVerify@QTest@@YA_N_NPBD11H@Z) referenced in function "private: void __thiscall
TestWaypointList::fillWaypoints(void)" (?fillWaypoints@TestWaypointList@@AAEXXZ)
我错过了链接哪些文件?没有QVERIFY
链接器错误就会消失。
头文件:
#include <QObject>
#include <QtTest/QtTest>
#include "waypointlist.h"
//
// Testing the waypoint list
//
class TestWaypointList : public QObject
{
Q_OBJECT
private:
WaypointList _waypointList;
public:
explicit TestWaypointList(QObject *parent = 0);
private slots:
void fillWaypoints();
};
cp:
//
// Fill the waypoint list
//
void TestWaypointList::fillWaypoints()
{
_waypointList = WaypointList();
.....
for (int i=0; i < TESTWPLISTCOUNT; i++) {
.....
TestWaypointList::_waypointList.updateOrAppend(id, timeframe);
}
QVERIFY(TestWaypointList::_waypointList.count() == 1); // causing the linker error
}