diff options
Diffstat (limited to 'src/testlib/qtestcase.h')
-rw-r--r-- | src/testlib/qtestcase.h | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index d33ed05..7d71891 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -119,11 +119,22 @@ class QTestData; namespace QTest { - template <typename T> +#ifndef Q_CC_NOKIAX86 + 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 *); @@ -168,6 +179,7 @@ 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) @@ -177,6 +189,20 @@ 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 <> Q_TESTLIB_EXPORT bool qCompare<float>(float const &t1, float const &t2, @@ -233,7 +259,7 @@ namespace QTest return qCompare<qreal>(qreal(t1), t2, actual, expected, file, line); } -#elif defined(QT_COORD_TYPE) || defined(QT_ARCH_ARM) || defined(QT_NO_FPU) || defined(QT_ARCH_WINDOWSCE) +#elif defined(QT_COORD_TYPE) || defined(QT_ARCH_ARM) || defined(QT_NO_FPU) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) template <> inline bool qCompare<qreal, double>(qreal const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) @@ -289,6 +315,28 @@ namespace QTest return compare_string_helper(t1, t2, actual, expected, file, line); } #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 +#if defined(QT_ARCH_SYMBIAN) + template <typename T1, typename T2> + bool qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int); + + template <> + inline bool qCompare<qreal, double>(qreal const &t1, double const &t2, const char *actual, + const char *expected, const char *file, int line) + { + return qCompare<float>(float(t1), float(t2), actual, expected, file, line); + } + + template <> + inline bool qCompare<double, qreal>(double const &t1, qreal const &t2, const char *actual, + const char *expected, const char *file, int line) + { + return qCompare<float>(float(t1), float(t2), actual, expected, file, line); + } +#endif + inline bool qCompare(const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line) { @@ -322,13 +370,24 @@ namespace QTest return compare_string_helper(t1, t2, actual, expected, file, line); } + // 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) + { + return qCompare<int>(int(t1), t2, actual, expected, file, line); + } + + template <class T> inline bool qTest(const T& actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line) { return qCompare(actual, *static_cast<const T *>(QTest::qElementData(elementName, qMetaTypeId<T>())), actualStr, expected, file, line); - } + } } #undef QTEST_COMPARE_DECL |