diff options
author | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-08-10 13:15:24 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-10-30 13:07:19 +0000 |
commit | a2b58c1643b5c8b67cb18750ef2d565180a3a179 (patch) | |
tree | 58d598bdc5c897ef2b4ae6105b05796e832d72c6 /tests/auto/corelib/global | |
parent | 0659bb810beec671dc7167e3066ad3646ef5ca8b (diff) |
Implement qt_is_{inf,nan,finite} using std. library functions.
The previous implementations did not check the full mantissa. The result
was that certain NaN values were seen as +/-Infinity.
A nice benefit is that the generated code for this implementation is also
faster.
Task-number: QTBUG-47692
Change-Id: I1507ec579ccd9a2ab97da8cf83dabbc5d6e28597
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests/auto/corelib/global')
-rw-r--r-- | tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 6be8ff81cf..01ff3a6c7e 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -105,6 +105,18 @@ void tst_QNumeric::qNan() QVERIFY(qIsNaN(nan)); QVERIFY(qIsNaN(nan + 1)); QVERIFY(qIsNaN(-nan)); + + Q_STATIC_ASSERT(sizeof(double) == 8); +#ifdef Q_LITTLE_ENDIAN + const uchar bytes[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f }; +#else + const uchar bytes[] = { 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; +#endif + memcpy(&nan, bytes, 8); + QVERIFY(!qIsFinite(nan)); + QVERIFY(!qIsInf(nan)); + QVERIFY(qIsNaN(nan)); + double inf = qInf(); QVERIFY(inf > 0); QVERIFY(-inf < 0); |