From 7447d73327bbaec3aee0570a3120a1bb40b5e3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 12 Sep 2022 13:23:48 +0200 Subject: tst_QLocale: use fenv everywhere And remove the platform-specific code. fenv is available since c++11. Change-Id: Ia5540be93b54117d4b5e9c7579100039c151dcc5 Reviewed-by: Thiago Macieira --- tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 28 +++---------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'tests/auto/corelib') 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 #include - -#if defined(Q_OS_LINUX) && !defined(__UCLIBC__) -# include -# define QT_USE_FENV -#endif +#include #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) # include @@ -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 } -- cgit v1.2.3