diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-03-30 15:25:11 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-04-01 23:11:34 +0200 |
commit | 3a2e3625d1e710795233aff9601ae9219f498edc (patch) | |
tree | 8412e88b0cd74f4f0334a6f1199a152328e63361 /tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp | |
parent | 67a563e5c55df8de595822880d92e297f580e053 (diff) |
Use constants of the correct type in qnumeric NaN test
Replaces 0, 0.0, 1, 1.0 and 2.0 with zero, one and two constants of
the templated floating-point type, to avoid type-conversions which
might have meant the test only checked doubles, or similar.
Change-Id: Id9d4488f0cc7226b5b8958d2a204a76fe5ae469d
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp')
-rw-r--r-- | tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 3dbf477a91..43b97555de 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -195,21 +195,22 @@ void tst_QNumeric::checkNaN(F nan) QVERIFY(!qIsFinite(v)); \ QVERIFY(!qIsInf(v)); \ } while (0) + const F zero(0), one(1), two(2); - QVERIFY(!(0 > nan)); - QVERIFY(!(0 < nan)); - QVERIFY(!(0 == nan)); + QVERIFY(!(zero > nan)); + QVERIFY(!(zero < nan)); + QVERIFY(!(zero == nan)); QVERIFY(!(nan == nan)); CHECKNAN(nan); - CHECKNAN(nan + 1); - CHECKNAN(nan - 1); + CHECKNAN(nan + one); + CHECKNAN(nan - one); CHECKNAN(-nan); - CHECKNAN(nan * 2.0); - CHECKNAN(nan / 2.0); - CHECKNAN(1.0 / nan); - CHECKNAN(0.0 / nan); - CHECKNAN(0.0 * nan); + CHECKNAN(nan * two); + CHECKNAN(nan / two); + CHECKNAN(one / nan); + CHECKNAN(zero / nan); + CHECKNAN(zero * nan); // When any NaN is expected, any NaN will do: QCOMPARE(nan, nan); |