I didn't get why passing parameters to constructor may fail. Any way it's conceptually wrong to pass parameters to unit tests, since they are supposed to be the same every run to ensure stability of implementation code.
Code:
#include <QtTest/QtTest>
#include <QtCore/QDebug>
class TestQString: public QObject
{
Q_OBJECT
public:
TestQString(QObject *parent = 0, int argc = 0, char ** argv = 0);
private slots:
void toUpper();
};
TestQString::TestQString(QObject *parent, int argc, char ** argv)
: QObject(parent)
{
qDebug() << argc << argv;
}
void TestQString::toUpper()
{
QString str = "Hello";
QCOMPARE(str.toUpper(), QString("HELLO"));
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTEST_DISABLE_KEYPAD_NAVIGATION
TestQString tc(0, argc, argv);
return QTest::qExec(&tc, argc, argv);
}
#include "testqstring.moc"