I am looking for the unit testing frame of QT, and I saw that one strange thing - given that QString already applies the equality operator to constant four *
, I hope. QCOMPARE (QString ("1", "1")
to work only, but instead it is a linky error:
tst_untitled14test.obj: -1: Error: LNK2019: Unsecured External Symbol "bool __cdecl QTest :: qCompare & LT; Class QString, four constant [2]> (Class QString constants & amp; 4, four constant (& amp;) [2], Four constants *, four constant *, four constant *, integer) "(?? $ qCompare @ VQString @@ $$ BY01 $$ CBD @ QTest @@YA_NABVQString @@ AAY01 $$ CBDPBD22H @Z) In the referenced function" Private: Zero __thiscall Untitled14Test :: testCase1 (zero) "(testCase1 @ Untitled14Test @@AAE XXZ?)
Example code:
QVERIFY (Qestring ("1") == "1"); // this work QCOMPARE (QString ("1"), Qestring ("1"); // this work // QCOMPARE (QString ("1"), "1"); // causes a linker error!
Why is that so? Does QCOMPARE
do not use equality operator of 2 terms?
Edit: Since it was said in the comments, this project is created by Qt, the Creator's Unit Test Wizard (File-> New Project-> Other Project-> QT Unit test), it is definitely set up properly, and QT + = testlib
is included.
No comments:
Post a Comment