Merge "Test __fpclassify/__isinf/__isnan."

This commit is contained in:
Elliott Hughes 2017-11-02 16:54:40 +00:00 committed by Gerrit Code Review
commit eed523e7cb

View file

@ -177,10 +177,19 @@ TEST(MATH_TEST, signbit) {
} }
// Historical BSD cruft that isn't exposed in <math.h> any more. // Historical BSD cruft that isn't exposed in <math.h> any more.
extern "C" int __fpclassify(double);
extern "C" int __fpclassifyd(double); extern "C" int __fpclassifyd(double);
extern "C" int __fpclassifyf(float); extern "C" int __fpclassifyf(float);
extern "C" int __fpclassifyl(long double); extern "C" int __fpclassifyl(long double);
TEST(MATH_TEST, __fpclassify) {
ASSERT_EQ(FP_INFINITE, __fpclassify(HUGE_VAL));
ASSERT_EQ(FP_NAN, __fpclassify(nan("")));
ASSERT_EQ(FP_NORMAL, __fpclassify(1.0));
ASSERT_EQ(FP_SUBNORMAL, __fpclassify(double_subnormal()));
ASSERT_EQ(FP_ZERO, __fpclassify(0.0));
}
TEST(MATH_TEST, __fpclassifyd) { TEST(MATH_TEST, __fpclassifyd) {
#if defined(__GLIBC__) #if defined(__GLIBC__)
#define __fpclassifyd __fpclassify #define __fpclassifyd __fpclassify
@ -254,9 +263,15 @@ TEST(MATH_TEST, isinf_function) {
} }
// Historical BSD cruft that isn't exposed in <math.h> any more. // Historical BSD cruft that isn't exposed in <math.h> any more.
extern "C" int __isinf(double);
extern "C" int __isinff(float); extern "C" int __isinff(float);
extern "C" int __isinfl(long double); extern "C" int __isinfl(long double);
TEST(MATH_TEST, __isinf) {
ASSERT_FALSE(__isinf(123.0));
ASSERT_TRUE(__isinf(HUGE_VAL));
}
TEST(MATH_TEST, __isinff) { TEST(MATH_TEST, __isinff) {
ASSERT_FALSE(__isinff(123.0f)); ASSERT_FALSE(__isinff(123.0f));
ASSERT_TRUE(__isinff(HUGE_VALF)); ASSERT_TRUE(__isinff(HUGE_VALF));
@ -274,9 +289,15 @@ TEST(MATH_TEST, isnan_function) {
} }
// Historical BSD cruft that isn't exposed in <math.h> any more. // Historical BSD cruft that isn't exposed in <math.h> any more.
extern "C" int __isnan(double);
extern "C" int __isnanf(float); extern "C" int __isnanf(float);
extern "C" int __isnanl(long double); extern "C" int __isnanl(long double);
TEST(MATH_TEST, __isnan) {
ASSERT_FALSE(__isnan(123.0));
ASSERT_TRUE(__isnan(nan("")));
}
TEST(MATH_TEST, __isnanf) { TEST(MATH_TEST, __isnanf) {
ASSERT_FALSE(__isnanf(123.0f)); ASSERT_FALSE(__isnanf(123.0f));
ASSERT_TRUE(__isnanf(nanf(""))); ASSERT_TRUE(__isnanf(nanf("")));