diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-09-20 16:36:51 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-23 23:29:42 +0200 |
commit | e44f1dabe44f4979da5da7d5d50395883f3de684 (patch) | |
tree | fed290bdb7e900c5bf5855cb1dae7979ca14e6f1 /src/testlib/qtestcase.h | |
parent | ef23f5d9bd3d82a6a1b5c3adb50d6ad4bfe127bb (diff) |
QTestLib: clean up qCompare specialisation/overload mix
qCompare() was both overloaded and specialised, but always as a template.
This lead to the QIcon specialisation actually invoking
qCompare(QFlags<void*>, ...)
when specifically asking for qCompare<void*>() (detected by adding
underlying-type detection to QFlags).
Fix by preferring overloading and not specialising anything.
Change-Id: Ie001ebb9dfb0847c6c33a3f45177a61579fd61ee
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/testlib/qtestcase.h')
-rw-r--r-- | src/testlib/qtestcase.h | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 79ec4c6037..1bfefaf2b0 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -230,12 +230,10 @@ namespace QTest toString<T>(t1), toString<T>(t2), actual, expected, file, line); } - template <> - Q_TESTLIB_EXPORT bool qCompare<float>(float const &t1, float const &t2, + Q_TESTLIB_EXPORT bool qCompare(float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line); - template <> - Q_TESTLIB_EXPORT bool qCompare<double>(double const &t1, double const &t2, + Q_TESTLIB_EXPORT bool qCompare(double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line); inline bool compare_ptr_helper(const void *t1, const void *t2, const char *actual, @@ -267,18 +265,16 @@ namespace QTest template <typename T1, typename T2> bool qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int); - template <> - inline bool qCompare<double, float>(double const &t1, float const &t2, const char *actual, + inline bool qCompare(double const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) { - return qCompare<qreal>(qreal(t1), qreal(t2), actual, expected, file, line); + return qCompare(qreal(t1), qreal(t2), actual, expected, file, line); } - template <> - inline bool qCompare<float, double>(float const &t1, double const &t2, const char *actual, + inline bool qCompare(float const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) { - return qCompare<qreal>(qreal(t1), qreal(t2), actual, expected, file, line); + return qCompare(qreal(t1), qreal(t2), actual, expected, file, line); } template <typename T> @@ -307,29 +303,25 @@ namespace QTest return compare_ptr_helper(const_cast<const T1 *>(t1), static_cast<const T1 *>(const_cast<const T2 *>(t2)), actual, expected, file, line); } - template<> - inline bool qCompare<char>(const char *t1, const char *t2, const char *actual, + inline bool qCompare(const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line) { return compare_string_helper(t1, t2, actual, expected, file, line); } - template<> - inline bool qCompare<char>(char *t1, char *t2, const char *actual, const char *expected, + inline bool qCompare(char *t1, char *t2, const char *actual, const char *expected, const char *file, int line) { return compare_string_helper(t1, t2, actual, expected, file, line); } - /* The next two specializations are for MSVC that shows problems with implicit + /* The next two overloads are for MSVC that shows problems with implicit conversions */ - template<> inline bool qCompare(char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line) { return compare_string_helper(t1, t2, actual, expected, file, line); } - template<> inline bool qCompare(const char *t1, char *t2, const char *actual, const char *expected, const char *file, int line) { @@ -337,11 +329,10 @@ namespace QTest } // NokiaX86 and RVCT do not like implicitly comparing bool with int - template <> 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); + return qCompare(int(t1), t2, actual, expected, file, line); } |