diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2022-09-12 13:23:48 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2022-09-15 23:41:51 +0200 |
commit | 7447d73327bbaec3aee0570a3120a1bb40b5e3b7 (patch) | |
tree | bcdbe985f27ca9c100ebe135d0ae8cd0a93f260f /tests/auto/corelib | |
parent | 59e08d21058661d9972da4840a82e2bc80d02741 (diff) |
tst_QLocale: use fenv everywhere
And remove the platform-specific code.
fenv is available since c++11.
Change-Id: Ia5540be93b54117d4b5e9c7579100039c151dcc5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index c817d02634..47ca031d7f 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -23,11 +23,7 @@ #include <float.h> #include <math.h> - -#if defined(Q_OS_LINUX) && !defined(__UCLIBC__) -# include <fenv.h> -# define QT_USE_FENV -#endif +#include <fenv.h> #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) # include <stdlib.h> @@ -1487,25 +1483,12 @@ void tst_QLocale::infNaN() void tst_QLocale::fpExceptions() { +#if defined(FE_ALL_EXCEPT) && FE_ALL_EXCEPT != 0 // Check that double-to-string conversion doesn't throw floating point // exceptions when they are enabled. -#ifdef Q_OS_WIN -# ifndef _MCW_EM -# define _MCW_EM 0x0008001F -# endif -# ifndef _EM_INEXACT -# define _EM_INEXACT 0x00000001 -# endif - _clearfp(); - unsigned int oldbits = _controlfp(0 | _EM_INEXACT, _MCW_EM); -#endif - -#ifdef QT_USE_FENV fenv_t envp; fegetenv(&envp); feclearexcept(FE_ALL_EXCEPT); - feenableexcept(FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID); -#endif QString::number(1000.1245); QString::number(1.1); @@ -1513,12 +1496,7 @@ void tst_QLocale::fpExceptions() QVERIFY(true); -#ifdef Q_OS_WIN - _clearfp(); - _controlfp(oldbits, _MCW_EM); -#endif - -#ifdef QT_USE_FENV + QCOMPARE(fetestexcept(FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID), 0); fesetenv(&envp); #endif } |