#include <float.h>
#include <stdlib.h>
#include <stdio.h>
+#include <math-tests.h>
+
+#if !defined(FE_OVERFLOW) && !defined(FE_UNDERFLOW)
+/* If there's no support for the exceptions this test is checking,
+ then just return success and allow the test to be compiled. */
+# define fetestexcept(e) 1
+#endif
float zero = 0.0;
float inf = INFINITY;
puts ("nexttowardf+ failed");
++result;
}
- if (fetestexcept (FE_OVERFLOW) == 0)
+ if (EXCEPTION_TESTS (float) && fetestexcept (FE_OVERFLOW) == 0)
{
puts ("nexttowardf+ did not overflow");
++result;
puts ("nexttowardf- failed");
++result;
}
- if (fetestexcept (FE_OVERFLOW) == 0)
+ if (EXCEPTION_TESTS (float) && fetestexcept (FE_OVERFLOW) == 0)
{
puts ("nexttowardf- did not overflow");
++result;
puts ("nexttowardf+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (float) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardf+ did not underflow");
++result;
puts ("nexttowardf- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (float) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardf- did not underflow");
++result;
puts ("nexttowardf+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (float) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardf+ did not underflow");
++result;
puts ("nexttowardf+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (float) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardf+ did not underflow");
++result;
puts ("nexttowardf- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (float) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardf- did not underflow");
++result;
puts ("nexttowardf- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (float) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardf- did not underflow");
++result;
puts ("nexttoward+ failed");
++result;
}
- if (fetestexcept (FE_OVERFLOW) == 0)
+ if (EXCEPTION_TESTS (double) && fetestexcept (FE_OVERFLOW) == 0)
{
puts ("nexttoward+ did not overflow");
++result;
puts ("nexttoward- failed");
++result;
}
- if (fetestexcept (FE_OVERFLOW) == 0)
+ if (EXCEPTION_TESTS (double) && fetestexcept (FE_OVERFLOW) == 0)
{
puts ("nexttoward- did not overflow");
++result;
puts ("nexttoward+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttoward+ did not underflow");
++result;
puts ("nexttoward- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttoward- did not underflow");
++result;
puts ("nexttoward+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttoward+ did not underflow");
++result;
puts ("nexttoward+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttoward+ did not underflow");
++result;
puts ("nexttoward- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttoward- did not underflow");
++result;
puts ("nexttoward- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttoward- did not underflow");
++result;
}
-#ifndef NO_LONG_DOUBLE
long double li = INFINITY;
long double lm = LDBL_MAX;
feclearexcept (FE_ALL_EXCEPT);
puts ("nexttowardl+ failed");
++result;
}
- if (fetestexcept (FE_OVERFLOW) == 0)
+ if (EXCEPTION_TESTS (long double) && fetestexcept (FE_OVERFLOW) == 0)
{
puts ("nexttowardl+ did not overflow");
++result;
puts ("nexttowardl failed");
++result;
}
- if (fetestexcept (FE_OVERFLOW) == 0)
+ if (EXCEPTION_TESTS (long double) && fetestexcept (FE_OVERFLOW) == 0)
{
puts ("nexttowardl- did not overflow");
++result;
puts ("nexttowardl+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (long double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardl+ did not underflow");
++result;
puts ("nexttowardl- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (long double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardl- did not underflow");
++result;
puts ("nexttowardl+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (long double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardl+ did not underflow");
++result;
puts ("nexttowardl+ failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (long double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardl+ did not underflow");
++result;
puts ("nexttowardl- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (long double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardl- did not underflow");
++result;
puts ("nexttowardl- failed");
++result;
}
- if (fetestexcept (FE_UNDERFLOW) == 0)
+ if (EXCEPTION_TESTS (long double) && fetestexcept (FE_UNDERFLOW) == 0)
{
puts ("nexttowardl- did not underflow");
++result;
}
-#endif
return result;
}