summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-12-04 09:58:43 +0100
committerLiang Qi <liang.qi@qt.io>2018-12-04 09:58:43 +0100
commit5d5c00c67682bce105197b659687fd1fee8f60cf (patch)
tree686e41dc3ea121235fb73afb9157ed603f1bfeff /src/testlib
parentf213e818f03d35cb82e3daf187415197fd156f8e (diff)
parentb82559244e2dc03f1ceff66bb67630df4300dc7c (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts: src/gui/painting/qdrawhelper.cpp Change-Id: I4916e07b635e1d3830e9b46ef7914f99bec3098e
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestcase.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index a9e2cc5ea3..ba03384db5 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -2500,7 +2500,16 @@ bool QTest::qCompare(qfloat16 const &t1, qfloat16 const &t2, const char *actual,
bool QTest::qCompare(float const &t1, float const &t2, const char *actual, const char *expected,
const char *file, int line)
{
- return compare_helper(qFuzzyCompare(t1, t2), "Compared floats are not the same (fuzzy compare)",
+ bool equal = false;
+ int cl1 = std::fpclassify(t1);
+ int cl2 = std::fpclassify(t2);
+ if (cl1 == FP_INFINITE)
+ equal = ((t1 < 0) == (t2 < 0)) && cl2 == FP_INFINITE;
+ else if (cl1 == FP_NAN)
+ equal = (cl2 == FP_NAN);
+ else
+ equal = qFuzzyCompare(t1, t2);
+ return compare_helper(equal, "Compared floats are not the same (fuzzy compare)",
toString(t1), toString(t2), actual, expected, file, line);
}