Sorry for the bad title, I have no idea how to title this question. Please edit and make it better.
I am writing a test using the Qt test framework, and I'm trying to write some useful output to be used by the QVERIFY2()
macro. All of the following statements have failed to compile with roughly the same error message:
QVERIFY2( spy.count() == 1, "Emitted signal pathChanged() was emitted " + spy.count() + " times instead of 1 time" );
QVERIFY2( spy.count() == 1, QString( "Emitted signal pathChanged() was emitted " ) + QString( spy.count() ) + QString( " times instead of 1 time" ) );
QVERIFY2( spy.count() == 1, "Emitted signal pathChanged() was emitted " + QString( spy.count() ) + " times instead of 1 time" );
The error message for the last attempt was:
PathTester.cxx: In member function ‘void PathTester::testReservePath()’:
PathTester.cxx:241:128: error: cannot convert ‘QString’ to ‘const char*’ for argument ‘3’ to ‘bool QTest::qVerify(bool, const char*, const char*, const char*, int)’
PathTester.cxx:241:243: error: cannot convert ‘QString’ to ‘const char*’ for argument ‘3’ to ‘bool QTest::qVerify(bool, const char*, const char*, const char*, int)’
What am I doing wrong? How can I write that correctly?