diff options
Diffstat (limited to 'test/std/depr/depr.c.headers/math_h.pass.cpp')
-rw-r--r-- | test/std/depr/depr.c.headers/math_h.pass.cpp | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/test/std/depr/depr.c.headers/math_h.pass.cpp b/test/std/depr/depr.c.headers/math_h.pass.cpp index ed12fcf73a8cf..7e1b2d110642e 100644 --- a/test/std/depr/depr.c.headers/math_h.pass.cpp +++ b/test/std/depr/depr.c.headers/math_h.pass.cpp @@ -9,9 +9,6 @@ // <math.h> -// NOTE: isinf and isnan are tested separately because they are expected to fail -// on linux. We don't want their expected failure to hide other failures in this file. - #include <math.h> #include <type_traits> #include <cassert> @@ -631,6 +628,29 @@ void test_isgreaterequal() assert(isgreaterequal(-1.0, 0.F) == false); } +void test_isinf() +{ +#ifdef isinf +#error isinf defined +#endif + static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), ""); + + typedef decltype(isinf((double)0)) DoubleRetType; +#ifndef __linux__ + static_assert((std::is_same<DoubleRetType, bool>::value), ""); +#else + // GLIBC < 2.26 defines 'isinf(double)' with a return type of 'int' in + // all C++ dialects. The test should tolerate this. + // See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439 + static_assert((std::is_same<DoubleRetType, bool>::value + || std::is_same<DoubleRetType, int>::value), ""); +#endif + + static_assert((std::is_same<decltype(isinf(0)), bool>::value), ""); + static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), ""); + assert(isinf(-1.0) == false); +} + void test_isless() { #ifdef isless @@ -688,6 +708,29 @@ void test_islessgreater() assert(islessgreater(-1.0, 0.F) == true); } +void test_isnan() +{ +#ifdef isnan +#error isnan defined +#endif + static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), ""); + + typedef decltype(isnan((double)0)) DoubleRetType; +#ifndef __linux__ + static_assert((std::is_same<DoubleRetType, bool>::value), ""); +#else + // GLIBC < 2.26 defines 'isnan(double)' with a return type of 'int' in + // all C++ dialects. The test should tolerate this. + // See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439 + static_assert((std::is_same<DoubleRetType, bool>::value + || std::is_same<DoubleRetType, int>::value), ""); +#endif + + static_assert((std::is_same<decltype(isnan(0)), bool>::value), ""); + static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), ""); + assert(isnan(-1.0) == false); +} + void test_isunordered() { #ifdef isunordered @@ -1443,9 +1486,11 @@ int main() test_isnormal(); test_isgreater(); test_isgreaterequal(); + test_isinf(); test_isless(); test_islessequal(); test_islessgreater(); + test_isnan(); test_isunordered(); test_acosh(); test_asinh(); |