1
我想在我的代碼中使用QTest宏QCOMPARE,但我收到錯誤。錯誤使用QTest宏QCOMPARE
QTestString.h
#ifndef QTESTSTRING_H
#define QTESTSTRING_H
#include <QtCore/QString>
#include <QtTest/QtTest>
class TestqstringTest : public QObject
{
Q_OBJECT
public:
TestqstringTest();
private slots:
void testCase1();
};
#endif // QTESTSTRING_H
QTestString.cpp
#include "QTestString.h"
TestqstringTest::TestqstringTest()
{
testCase1();
}
void TestqstringTest::testCase1()
{
QString str = "Hello";
QCOMPARE(str.toUpper(),(QString)"hELLO");
}
的main.cpp
#include "QTestString.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TestqstringTest *test = new TestqstringTest();
return a.exec();
}
不過,我收到以下錯誤:
ASSERT:文件qtestlog.cpp中的「QTest :: testLogger」,第266行程序 已意外完成。