qCompare: fix 'sign-compare' compilation warnings
- It seems, clang-tidy doesn't detect 'sign-comparison' problems in qtestlib templates. But it is being detected on compilation time. The cmp_<> API can be used for integer types to fix that warnings. The compilation output: /home/qt/work/base/qt5/qtbase/src/testlib/qtestcase.h:626:34: warning: comparison of integer expressions of different signedness: ‘const long long int’ and ‘const long unsigned int’ [-Wsign-compare] return compare_helper(t1 == t2, "Compared values are not the same", Task-number: QTBUG-105464 Change-Id: I00c2632ec1a8c8c2f122e0b6578b16e5b0719a9e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
24424fa939
commit
70e92f49c3
@ -15,6 +15,7 @@
|
||||
#include <QtCore/qtemporarydir.h>
|
||||
#include <QtCore/qthread.h>
|
||||
#include <QtCore/qxpfunctional.h>
|
||||
#include <QtCore/q20utility.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -623,10 +624,18 @@ namespace QTest
|
||||
using D1 = std::decay_t<T1>;
|
||||
using D2 = std::decay_t<T2>;
|
||||
using Internal::genericToString;
|
||||
return compare_helper(t1 == t2, "Compared values are not the same",
|
||||
std::addressof(t1), std::addressof(t2),
|
||||
genericToString<D1>, genericToString<D2>,
|
||||
actual, expected, file, line);
|
||||
if constexpr (QtPrivate::is_standard_or_extended_integer_type_v<T1>
|
||||
&& QtPrivate::is_standard_or_extended_integer_type_v<T2>) {
|
||||
return compare_helper(q20::cmp_equal(t1, t2), "Compared values are not the same",
|
||||
std::addressof(t1), std::addressof(t2),
|
||||
genericToString<D1>, genericToString<D2>,
|
||||
actual, expected, file, line);
|
||||
} else {
|
||||
return compare_helper(t1 == t2, "Compared values are not the same",
|
||||
std::addressof(t1), std::addressof(t2),
|
||||
genericToString<D1>, genericToString<D2>,
|
||||
actual, expected, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool qCompare(double const &t1, float const &t2, const char *actual,
|
||||
|
Loading…
x
Reference in New Issue
Block a user