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>
This commit is contained in:
parent
67a563e5c5
commit
3a2e3625d1
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user