test-next.c (230102) | test-next.c (251241) |
---|---|
1/*- 2 * Copyright (c) 2005 David Schultz <das@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26 27/* 28 * Test the correctness of nextafter{,f,l} and nexttoward{,f,l}. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2005 David Schultz <das@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26 27/* 28 * Test the correctness of nextafter{,f,l} and nexttoward{,f,l}. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/tools/regression/lib/msun/test-next.c 230102 2012-01-14 08:11:40Z das $"); | 32__FBSDID("$FreeBSD: head/tools/regression/lib/msun/test-next.c 251241 2013-06-02 04:30:03Z das $"); |
33 34#include <fenv.h> 35#include <float.h> 36#include <math.h> 37#include <stdio.h> 38#include <stdlib.h> 39 40#ifdef __i386__ 41#include <ieeefp.h> 42#endif 43 | 33 34#include <fenv.h> 35#include <float.h> 36#include <math.h> 37#include <stdio.h> 38#include <stdlib.h> 39 40#ifdef __i386__ 41#include <ieeefp.h> 42#endif 43 |
44#define ALL_STD_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID |\ 45 FE_OVERFLOW | FE_UNDERFLOW) | 44#include "test-utils.h" 45 |
46#define test(exp, ans, ex) do { \ 47 double __ans = (ans); \ 48 feclearexcept(ALL_STD_EXCEPT); \ 49 _testl(#exp, __LINE__, (exp), __ans, (ex)); \ 50} while (0) 51#define testf(exp, ans, ex) do { \ 52 float __ans = (ans); \ 53 feclearexcept(ALL_STD_EXCEPT); \ --- 176 unchanged lines hidden (view full) --- 230 231static void 232_testl(const char *exp, int line, long double actual, long double expected, 233 int except) 234{ 235 int actual_except; 236 237 actual_except = fetestexcept(ALL_STD_EXCEPT); | 46#define test(exp, ans, ex) do { \ 47 double __ans = (ans); \ 48 feclearexcept(ALL_STD_EXCEPT); \ 49 _testl(#exp, __LINE__, (exp), __ans, (ex)); \ 50} while (0) 51#define testf(exp, ans, ex) do { \ 52 float __ans = (ans); \ 53 feclearexcept(ALL_STD_EXCEPT); \ --- 176 unchanged lines hidden (view full) --- 230 231static void 232_testl(const char *exp, int line, long double actual, long double expected, 233 int except) 234{ 235 int actual_except; 236 237 actual_except = fetestexcept(ALL_STD_EXCEPT); |
238 if (actual != expected && !(isnan(actual) && isnan(expected))) { | 238 if (!fpequal(actual, expected)) { |
239 fprintf(stderr, "%d: %s returned %La, expecting %La\n", 240 line, exp, actual, expected); 241 abort(); 242 } 243 if (actual_except != except) { 244 fprintf(stderr, "%d: %s raised 0x%x, expecting 0x%x\n", 245 line, exp, actual_except, except); 246 abort(); --- 19 unchanged lines hidden --- | 239 fprintf(stderr, "%d: %s returned %La, expecting %La\n", 240 line, exp, actual, expected); 241 abort(); 242 } 243 if (actual_except != except) { 244 fprintf(stderr, "%d: %s raised 0x%x, expecting 0x%x\n", 245 line, exp, actual_except, except); 246 abort(); --- 19 unchanged lines hidden --- |