summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-06-29 07:35:39 (GMT)
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-06-29 07:35:39 (GMT)
commitc1e73ebf3b2f15646ba6b755a37b12e65881e9ae (patch)
tree924254550510249977afe0a1874246bfcc0c6b24 /src/testlib
parent9875973c21660afbe19430d9a71fe7c22a8feb4c (diff)
downloadQt-c1e73ebf3b2f15646ba6b755a37b12e65881e9ae.zip
Qt-c1e73ebf3b2f15646ba6b755a37b12e65881e9ae.tar.gz
Qt-c1e73ebf3b2f15646ba6b755a37b12e65881e9ae.tar.bz2
Removed the need for NokiaX86 compiler specific hacks from qtestcase.h by
properly exporting the toString specializations in qtestcase.cpp.
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestcase.cpp114
-rw-r--r--src/testlib/qtestcase.h38
2 files changed, 64 insertions, 88 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 38e63cf..a38ae70 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -850,7 +850,7 @@ static void qParseArgs(int argc, char *argv[])
" -median n : Sets the number of median iterations.\n"
" -vb : Print out verbose benchmarking information.\n"
#ifndef QT_NO_PROCESS
-// Will be enabled when tools are integrated.
+// Will be enabled when tools are integrated.
// " -chart : Runs the chart generator after the test. No output is printed to the console\n"
#endif
"\n"
@@ -1011,7 +1011,7 @@ QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container)
if (count == 1)
return container.at(0);
-
+
QList<QBenchmarkResult> containerCopy = container;
qSort(containerCopy);
@@ -1061,7 +1061,7 @@ static void qInvokeTestMethodDataEntry(char *slot)
QTestResult::currentDataTag()
? QTestResult::currentDataTag() : "");
- invokeOk = QMetaObject::invokeMethod(QTest::currentTestObject, slot,
+ invokeOk = QMetaObject::invokeMethod(QTest::currentTestObject, slot,
Qt::DirectConnection);
if (!invokeOk)
QTestResult::addFailure("Unable to execute slot", __FILE__, __LINE__);
@@ -1082,7 +1082,7 @@ static void qInvokeTestMethodDataEntry(char *slot)
if (i > -1) // iteration -1 is the warmup iteration.
results.append(QBenchmarkTestMethodData::current->result);
- if (QBenchmarkTestMethodData::current->isBenchmark() &&
+ if (QBenchmarkTestMethodData::current->isBenchmark() &&
QBenchmarkGlobalData::current->verboseOutput) {
if (i == -1) {
qDebug() << "warmup stage result :" << QBenchmarkTestMethodData::current->result.value;
@@ -1213,13 +1213,13 @@ void *fetchData(QTestData *data, const char *tagName, int typeId)
/*!
\fn char* QTest::toHexRepresentation(const char *ba, int length)
-
+
Returns a pointer to a string that is the string \a ba represented
as a space-separated sequence of hex characters. If the input is
considered too long, it is truncated. A trucation is indicated in
the returned string as an ellipsis at the end.
- \a length is the length of the string \a ba.
+ \a length is the length of the string \a ba.
*/
char *toHexRepresentation(const char *ba, int length)
{
@@ -1278,56 +1278,56 @@ char *toHexRepresentation(const char *ba, int length)
return result;
}
-static void qInvokeTestMethods(QObject *testObject)
-{
- const QMetaObject *metaObject = testObject->metaObject();
- QTEST_ASSERT(metaObject);
-
- QTestLog::startLogging();
-
- QTestResult::setCurrentTestFunction("initTestCase");
- QTestResult::setCurrentTestLocation(QTestResult::DataFunc);
- QTestTable::globalTestTable();
- QMetaObject::invokeMethod(testObject, "initTestCase_data", Qt::DirectConnection);
-
- if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) {
- QTestResult::setCurrentTestLocation(QTestResult::InitFunc);
- QMetaObject::invokeMethod(testObject, "initTestCase");
-
- // finishedCurrentTestFunction() resets QTestResult::testFailed(), so use a local copy.
- const bool previousFailed = QTestResult::testFailed();
- QTestResult::finishedCurrentTestFunction();
-
- if(!QTestResult::skipCurrentTest() && !previousFailed) {
-
- if (lastTestFuncIdx >= 0) {
- for (int i = 0; i <= lastTestFuncIdx; ++i) {
- if (!qInvokeTestMethod(metaObject->method(testFuncs[i].function).signature(),
- testFuncs[i].data))
- break;
- }
- } else {
- int methodCount = metaObject->methodCount();
- for (int i = 0; i < methodCount; ++i) {
- QMetaMethod slotMethod = metaObject->method(i);
- if (!isValidSlot(slotMethod))
- continue;
- if (!qInvokeTestMethod(slotMethod.signature()))
- break;
- }
- }
- }
-
- QTestResult::setSkipCurrentTest(false);
- QTestResult::setCurrentTestFunction("cleanupTestCase");
- QMetaObject::invokeMethod(testObject, "cleanupTestCase");
- }
- QTestResult::finishedCurrentTestFunction();
- QTestResult::setCurrentTestFunction(0);
- QTestTable::clearGlobalTestTable();
-
- QTestLog::stopLogging();
-}
+static void qInvokeTestMethods(QObject *testObject)
+{
+ const QMetaObject *metaObject = testObject->metaObject();
+ QTEST_ASSERT(metaObject);
+
+ QTestLog::startLogging();
+
+ QTestResult::setCurrentTestFunction("initTestCase");
+ QTestResult::setCurrentTestLocation(QTestResult::DataFunc);
+ QTestTable::globalTestTable();
+ QMetaObject::invokeMethod(testObject, "initTestCase_data", Qt::DirectConnection);
+
+ if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) {
+ QTestResult::setCurrentTestLocation(QTestResult::InitFunc);
+ QMetaObject::invokeMethod(testObject, "initTestCase");
+
+ // finishedCurrentTestFunction() resets QTestResult::testFailed(), so use a local copy.
+ const bool previousFailed = QTestResult::testFailed();
+ QTestResult::finishedCurrentTestFunction();
+
+ if(!QTestResult::skipCurrentTest() && !previousFailed) {
+
+ if (lastTestFuncIdx >= 0) {
+ for (int i = 0; i <= lastTestFuncIdx; ++i) {
+ if (!qInvokeTestMethod(metaObject->method(testFuncs[i].function).signature(),
+ testFuncs[i].data))
+ break;
+ }
+ } else {
+ int methodCount = metaObject->methodCount();
+ for (int i = 0; i < methodCount; ++i) {
+ QMetaMethod slotMethod = metaObject->method(i);
+ if (!isValidSlot(slotMethod))
+ continue;
+ if (!qInvokeTestMethod(slotMethod.signature()))
+ break;
+ }
+ }
+ }
+
+ QTestResult::setSkipCurrentTest(false);
+ QTestResult::setCurrentTestFunction("cleanupTestCase");
+ QMetaObject::invokeMethod(testObject, "cleanupTestCase");
+ }
+ QTestResult::finishedCurrentTestFunction();
+ QTestResult::setCurrentTestFunction(0);
+ QTestTable::clearGlobalTestTable();
+
+ QTestLog::stopLogging();
+}
} // namespace
@@ -1788,7 +1788,7 @@ bool QTest::qCompare<double>(double const &t1, double const &t2, const char *act
}
#define COMPARE_IMPL2(TYPE, FORMAT) \
-template <> char *QTest::toString<TYPE >(const TYPE &t) \
+template <> Q_TESTLIB_EXPORT char *QTest::toString<TYPE >(const TYPE &t) \
{ \
char *msg = new char[128]; \
qt_snprintf(msg, 128, #FORMAT, t); \
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index b104e93..cda6eca 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -119,22 +119,12 @@ class QTestData;
namespace QTest
{
-#ifndef Q_CC_NOKIAX86
- template <typename T>
+ template <typename T>
inline char *toString(const T &)
{
return 0;
}
-#else
- // Nokia X86 compiler bug:
- // does not export template specializations if parent template is inline
- template <typename T>
- Q_TESTLIB_EXPORT char *toString(const T &)
- {
- return 0;
- }
-#endif
-
+
Q_TESTLIB_EXPORT char *toHexRepresentation(const char *ba, int length);
Q_TESTLIB_EXPORT char *toString(const char *);
@@ -179,7 +169,6 @@ namespace QTest
}
Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag);
-#ifndef Q_CC_NOKIAX86
template <typename T>
inline bool qCompare(T const &t1, T const &t2, const char *actual, const char *expected,
const char *file, int line)
@@ -189,19 +178,6 @@ namespace QTest
: compare_helper(false, "Compared values are not the same",
toString<T>(t1), toString<T>(t2), actual, expected, file, line);
}
-#else
- // Nokia X86 compiler bug:
- // does not export template specializations if parent template is inline
- template <typename T>
- Q_TESTLIB_EXPORT bool qCompare(T const &t1, T const &t2, const char *actual, const char *expected,
- const char *file, int line)
- {
- return (t1 == t2)
- ? compare_helper(true, "COMPARE()", file, line)
- : compare_helper(false, "Compared values are not the same",
- toString<T>(t1), toString<T>(t2), actual, expected, file, line);
- }
-#endif
template <>
@@ -316,8 +292,8 @@ namespace QTest
}
#else /* QTEST_NO_SPECIALIZATIONS */
-// In Synmbian we have QTEST_NO_SPECIALIZATIONS defined, but still float related specialization
-// Should be uses. If QTEST_NO_SPECIALIZATIONS is enabled we get ambiguous overload errors
+// In Symbian we have QTEST_NO_SPECIALIZATIONS defined, but still float related specialization
+// should be used. If QTEST_NO_SPECIALIZATIONS is enabled we get ambiguous overload errors.
#if defined(QT_ARCH_SYMBIAN)
template <typename T1, typename T2>
bool qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int);
@@ -370,12 +346,12 @@ namespace QTest
return compare_string_helper(t1, t2, actual, expected, file, line);
}
- // NokiaX86 and RVCT do not like implicitly comparing bool with int
+ // NokiaX86 and RVCT do not like implicitly comparing bool with int
#ifndef QTEST_NO_SPECIALIZATIONS
template <>
#endif
inline bool qCompare(bool const &t1, int const &t2,
- const char *actual, const char *expected, const char *file, int line)
+ const char *actual, const char *expected, const char *file, int line)
{
return qCompare<int>(int(t1), t2, actual, expected, file, line);
}
@@ -387,7 +363,7 @@ namespace QTest
{
return qCompare(actual, *static_cast<const T *>(QTest::qElementData(elementName,
qMetaTypeId<T>())), actualStr, expected, file, line);
- }
+ }
}
#undef QTEST_COMPARE_DECL