summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
index 94f0afa5ed..a661b0388e 100644
--- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
+++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
@@ -430,6 +430,13 @@ void tst_qfloat16::finite()
QVERIFY(!qIsInf(value));
QVERIFY(!qIsNaN(value));
QCOMPARE(qFpClassify(value), mode);
+
+ // *NOT* using QCOMPARE() on finite qfloat16 values, since that uses fuzzy
+ // comparison, and we need exact here.
+ const qfloat16 zero(0), plus(+1), minus(-1);
+ const qfloat16 magnitude = (value < zero) ? -value : value;
+ QVERIFY(value.copySign(plus) == magnitude);
+ QVERIFY(value.copySign(minus) == -magnitude);
}
void tst_qfloat16::properties()
@@ -534,7 +541,9 @@ void tst_qfloat16::limits() // See also: qNaN() and infinity()
QVERIFY(Bounds::denorm_min() / rose == zero);
if (overOptimized)
QEXPECT_FAIL("", "Over-optimized on ARM", Continue);
- QVERIFY(-Bounds::denorm_min() / rose == -zero);
+ const qfloat16 under = (-Bounds::denorm_min()) / rose;
+ QVERIFY(under == -zero);
+ QCOMPARE(qfloat16(1).copySign(under), qfloat16(-1));
}
QTEST_APPLESS_MAIN(tst_qfloat16)