Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.7
-
None
-
win64
vc14
qt 5.7
cmake
environment compiles and passes many other QTests utilising QFETCH macro with other containers like QList.
Description
http://doc.qt.io/qt-5/qmap.html
------------------------- updated description-----------------------------
The documentation says qmap declaration is QMap<key, value> map;
So my comma in between the key and value in the map should be valid.
Thiago macieira suggested using a typedef. This is a very hacky workaround that will get it to compile but I can't see how this isn't a bug? using documented declaration obscurely causes it to fail. At the very least this should be documented somewhere.
------------------------- original description-----------------------------
Have tried several different key value pairs on clean builds to no avail. All fail spectacularly seemingly because of the bad macro expansion. Errors include:
warning C4002: too many actual parameters for macro 'QFETCH' error C2146: syntax error: missing '>' before identifier 'QString' error C2976: 'QMap': too few template arguments note: see declaration of 'QMap' error C2061: syntax error: identifier 'qData' error C2512: 'QMap': no appropriate default constructor available note: No constructor could take the source type, or constructor overload resolution was ambiguous error C2059: syntax error: ')' error C2143: syntax error: missing ';' before '{' error C2059: syntax error: ')' error C2143: syntax error: missing ';' before '}' error C2143: syntax error: missing ';' before '}' fatal error C1004: unexpected end-of-file found
testclass.h:
#pragma once #include <qtest.h> #include <QMap> #include <QString> class TestClass : public QObject { Q_OBJECT private slots: void mapTest_data() { QTest::addColumn< QMap< QString, QString > >,( "aMap" ); QTest::newRow( "test1" ) << QMap< QString, QString >( {"0", "pizza"} ); } void mapTest() { QFETCH( QMap< QString, QString >, aMap ); QCOMPARE( aMap["0"], "pizza" ); } };
main.cpp :
#include <QApplication> #include "testclass.h" int main( int argc, char *argv[] ) { QApplication app( argc, argv ); TestClass tc; int res = QTest::qExec( &tc, argc, argv ) ); return res; }