⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)
QCOMPARE requires explicit casting to handle properly comparison between quint and some number
Red Baron last edited by
I'm wondering if this is made on purpose or is a bug but the following line
quint16 num = 0; QCOMPARE(num, 0);
cannot be compiled and the error
undefined reference to `bool QTest::qCompare<unsigned short, int>(unsigned short const&, int const&, char const*, char const*, char const*, int)'
However if I do
everything compiles just fine. I do realize that by forcing the tester to do explicit casting he is forced to check the value that he is actually entering (if we have
quint8for example and compare it to
1000, this clearly introduces a problem) but on the other hand every single time the tester needs to make trivial comparisons he needs to typecast.
Also the behaviour above is easily avoided by simply replacing
QVERIFY((num == 0) == true);
What version of Qt are you using ?
With which compiler ?
On what OS ?