QStringBuilder: code tidies in the tests
Including other headers, while defining very questionable macro names, can and will result in trouble. Stop doing that. While at it, move from including <QtTest> to include-what-you-use, and clean up the code a bit. Change-Id: Idb02ef2b612c0805baecac3ce6edd435609aca4c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
c2085c26cf
commit
77a8005dcb
@ -26,7 +26,8 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
// Do not include anything in this file. We are being #included with
|
||||||
|
// a bunch of defines that may break other legitimate code.
|
||||||
|
|
||||||
#define LITERAL "some literal"
|
#define LITERAL "some literal"
|
||||||
#define LITERAL_LEN (sizeof(LITERAL)-1)
|
#define LITERAL_LEN (sizeof(LITERAL)-1)
|
||||||
@ -46,7 +47,6 @@
|
|||||||
|
|
||||||
#ifndef P
|
#ifndef P
|
||||||
# error You need to define P
|
# error You need to define P
|
||||||
# define P +
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS
|
//fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS
|
||||||
|
@ -30,13 +30,14 @@
|
|||||||
// SCENARIO 1
|
// SCENARIO 1
|
||||||
// this is the "no harm done" version. Only operator% is active,
|
// this is the "no harm done" version. Only operator% is active,
|
||||||
// with NO_CAST * defined
|
// with NO_CAST * defined
|
||||||
#define P %
|
|
||||||
#undef QT_USE_QSTRINGBUILDER
|
#undef QT_USE_QSTRINGBUILDER
|
||||||
#define QT_NO_CAST_FROM_ASCII
|
#define QT_NO_CAST_FROM_ASCII
|
||||||
#define QT_NO_CAST_TO_ASCII
|
#define QT_NO_CAST_TO_ASCII
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringBuilder>
|
||||||
|
#include <QtTest/QTest>
|
||||||
|
|
||||||
#define LITERAL "some literal"
|
#define LITERAL "some literal"
|
||||||
|
|
||||||
@ -50,7 +51,10 @@ private slots:
|
|||||||
void scenario() { runScenario(); }
|
void scenario() { runScenario(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define P %
|
||||||
#include "stringbuilder.cpp"
|
#include "stringbuilder.cpp"
|
||||||
|
#undef P
|
||||||
|
|
||||||
#include "tst_qstringbuilder1.moc"
|
#include "tst_qstringbuilder1.moc"
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_QStringBuilder1)
|
QTEST_APPLESS_MAIN(tst_QStringBuilder1)
|
||||||
|
@ -31,13 +31,14 @@
|
|||||||
// this is the "full" version. Operator+ is replaced by a QStringBuilder
|
// this is the "full" version. Operator+ is replaced by a QStringBuilder
|
||||||
// based version
|
// based version
|
||||||
// with NO_CAST * defined
|
// with NO_CAST * defined
|
||||||
#define P +
|
|
||||||
#define QT_USE_QSTRINGBUILDER
|
#define QT_USE_QSTRINGBUILDER
|
||||||
#define QT_NO_CAST_FROM_ASCII
|
#define QT_NO_CAST_FROM_ASCII
|
||||||
#define QT_NO_CAST_TO_ASCII
|
#define QT_NO_CAST_TO_ASCII
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringBuilder>
|
||||||
|
#include <QtTest/QTest>
|
||||||
|
|
||||||
#define LITERAL "some literal"
|
#define LITERAL "some literal"
|
||||||
|
|
||||||
@ -51,7 +52,10 @@ private slots:
|
|||||||
void scenario() { runScenario(); }
|
void scenario() { runScenario(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define P +
|
||||||
#include "../qstringbuilder1/stringbuilder.cpp"
|
#include "../qstringbuilder1/stringbuilder.cpp"
|
||||||
|
#undef P
|
||||||
|
|
||||||
#include "tst_qstringbuilder2.moc"
|
#include "tst_qstringbuilder2.moc"
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_QStringBuilder2)
|
QTEST_APPLESS_MAIN(tst_QStringBuilder2)
|
||||||
|
@ -30,13 +30,14 @@
|
|||||||
// SCENARIO 3
|
// SCENARIO 3
|
||||||
// this is the "no harm done" version. Only operator% is active,
|
// this is the "no harm done" version. Only operator% is active,
|
||||||
// with NO_CAST * _not_ defined
|
// with NO_CAST * _not_ defined
|
||||||
#define P %
|
|
||||||
#undef QT_USE_QSTRINGBUILDER
|
#undef QT_USE_QSTRINGBUILDER
|
||||||
#undef QT_NO_CAST_FROM_ASCII
|
#undef QT_NO_CAST_FROM_ASCII
|
||||||
#undef QT_NO_CAST_TO_ASCII
|
#undef QT_NO_CAST_TO_ASCII
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringBuilder>
|
||||||
|
#include <QtTest/QTest>
|
||||||
|
|
||||||
#define LITERAL "some literal"
|
#define LITERAL "some literal"
|
||||||
|
|
||||||
@ -50,7 +51,10 @@ private slots:
|
|||||||
void scenario() { runScenario(); }
|
void scenario() { runScenario(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define P %
|
||||||
#include "../qstringbuilder1/stringbuilder.cpp"
|
#include "../qstringbuilder1/stringbuilder.cpp"
|
||||||
|
#undef P
|
||||||
|
|
||||||
#include "tst_qstringbuilder3.moc"
|
#include "tst_qstringbuilder3.moc"
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_QStringBuilder3)
|
QTEST_APPLESS_MAIN(tst_QStringBuilder3)
|
||||||
|
@ -31,13 +31,14 @@
|
|||||||
// this is the "full" version. Operator+ is replaced by a QStringBuilder
|
// this is the "full" version. Operator+ is replaced by a QStringBuilder
|
||||||
// based version
|
// based version
|
||||||
// with NO_CAST * _not_ defined
|
// with NO_CAST * _not_ defined
|
||||||
#define P +
|
|
||||||
#define QT_USE_QSTRINGBUILDER
|
#define QT_USE_QSTRINGBUILDER
|
||||||
#undef QT_NO_CAST_FROM_ASCII
|
#undef QT_NO_CAST_FROM_ASCII
|
||||||
#undef QT_NO_CAST_TO_ASCII
|
#undef QT_NO_CAST_TO_ASCII
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringBuilder>
|
||||||
|
#include <QtTest/QTest>
|
||||||
|
|
||||||
#define LITERAL "some literal"
|
#define LITERAL "some literal"
|
||||||
|
|
||||||
@ -51,7 +52,10 @@ private slots:
|
|||||||
void scenario() { runScenario(); }
|
void scenario() { runScenario(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define P +
|
||||||
#include "../qstringbuilder1/stringbuilder.cpp"
|
#include "../qstringbuilder1/stringbuilder.cpp"
|
||||||
|
#undef P
|
||||||
|
|
||||||
#include "tst_qstringbuilder4.moc"
|
#include "tst_qstringbuilder4.moc"
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_QStringBuilder4)
|
QTEST_APPLESS_MAIN(tst_QStringBuilder4)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user