summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/selftests/float
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-07-28 13:30:03 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-07-28 21:26:55 +0200
commit92f8043759dc97191a1208ed60d46ef44ce96c52 (patch)
tree30fda0932f83bfbfa5952bb0c8166736ae4eda15 /tests/auto/testlib/selftests/float
parent42970e490af00cd9baff1c54f4f00d982b21586a (diff)
Update float16 part of TestLib selftest
In commit 9bad096c091b2c2106c2f325dfca74be111eee58 I gave qFuzzyIsNull(qfloat16) a more forgiving threshold, consistent with qFloatCompare(qfloat16, qfloat16)'s fractional threshold. The selftest failed to catch two of the tests failing, so fix one of them to use different values, and remove one. Updated test expection for txt and deleted for other formats, as they're skipped (in tst_selftests.cpp) for this test. Refined the generator script to know about this test only being tested for txt. Pick-to: 6.2 Change-Id: I109547cf92178bb9f5ff0b06e0b3bb40c881b41b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/testlib/selftests/float')
-rw-r--r--tests/auto/testlib/selftests/float/tst_float.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/testlib/selftests/float/tst_float.cpp b/tests/auto/testlib/selftests/float/tst_float.cpp
index 6084b464e2..ad03176302 100644
--- a/tests/auto/testlib/selftests/float/tst_float.cpp
+++ b/tests/auto/testlib/selftests/float/tst_float.cpp
@@ -182,20 +182,20 @@ void tst_float::float16Comparisons_data() const
QTest::addColumn<qfloat16>("operandLeft");
QTest::addColumn<qfloat16>("operandRight");
const qfloat16 zero(0), one(1);
- const qfloat16 tiny(QTestPrivate::isRunningArmOnX86() ? 0.00099f : 0.001f);
+ const qfloat16 tiny(9.756e-03f);
QTest::newRow("should FAIL 1") << one << qfloat16(3);
QTest::newRow("should PASS 1") << zero << zero;
- QTest::newRow("should FAIL 2") << qfloat16(1e-3f) << qfloat16(3e-3f);
// QCOMPARE for uses qFuzzyCompare(), which ignores differences of one part
// in 102.5 and considers any two qFuzzyIsNull() values, i.e. values smaller
- // than 1e-3, equal
+ // than 1/102.5, equal
+ QTest::newRow("should FAIL 2") << qfloat16(.01f) << qfloat16(.03f);
QTest::newRow("should PASS 2") << qfloat16(1001) << qfloat16(1002);
QTest::newRow("should FAIL 3") << qfloat16(98) << qfloat16(99);
QTest::newRow("should PASS 3") << tiny << -tiny;
// ... which gets a bit unreliable near to the type's bounds
- QTest::newRow("should FAIL 4") << qfloat16(1.01e-3f) << qfloat16(0.99e-3f);
+ QTest::newRow("should FAIL 4") << qfloat16(10e-3f) << qfloat16(9.7e-3f);
QTest::newRow("should PASS 4") << qfloat16(6e4) + qfloat16(700) << qfloat16(6e4) + qfloat16(1200);
QTest::newRow("should FAIL 5") << qfloat16(6e4) - qfloat16(600) << qfloat16(6e4) - qfloat16(1200);