csqrt_test.c (271296) | csqrt_test.c (287297) |
---|---|
1/*- 2 * Copyright (c) 2007 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 * Tests for csqrt{,f}() 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2007 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 * Tests for csqrt{,f}() 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/tools/regression/lib/msun/test-csqrt.c 271296 2014-09-09 02:58:58Z ngie $"); | 32__FBSDID("$FreeBSD: head/tools/regression/lib/msun/test-csqrt.c 287297 2015-08-29 19:47:20Z rodrigc $"); |
33 | 33 |
34#include <sys/param.h> 35 |
|
34#include <assert.h> 35#include <complex.h> 36#include <float.h> 37#include <math.h> 38#include <stdio.h> 39 40#include "test-utils.h" 41 | 36#include <assert.h> 37#include <complex.h> 38#include <float.h> 39#include <math.h> 40#include <stdio.h> 41 42#include "test-utils.h" 43 |
42#define N(i) (sizeof(i) / sizeof((i)[0])) 43 | |
44/* 45 * This is a test hook that can point to csqrtl(), _csqrt(), or to _csqrtf(). 46 * The latter two convert to float or double, respectively, and test csqrtf() 47 * and csqrt() with the same arguments. 48 */ 49long double complex (*t_csqrt)(long double complex); 50 51static long double complex --- 70 unchanged lines hidden (view full) --- 122 0x1.p30, 123 0x1.p-30, 124 }; 125 126 double a, b; 127 double x, y; 128 int i, j; 129 | 44/* 45 * This is a test hook that can point to csqrtl(), _csqrt(), or to _csqrtf(). 46 * The latter two convert to float or double, respectively, and test csqrtf() 47 * and csqrt() with the same arguments. 48 */ 49long double complex (*t_csqrt)(long double complex); 50 51static long double complex --- 70 unchanged lines hidden (view full) --- 122 0x1.p30, 123 0x1.p-30, 124 }; 125 126 double a, b; 127 double x, y; 128 int i, j; 129 |
130 for (i = 0; i < N(tests); i += 4) { 131 for (j = 0; j < N(mults); j++) { | 130 for (i = 0; i < nitems(tests); i += 4) { 131 for (j = 0; j < nitems(mults); j++) { |
132 a = tests[i] * mults[j] * mults[j]; 133 b = tests[i + 1] * mults[j] * mults[j]; 134 x = tests[i + 2] * mults[j]; 135 y = tests[i + 3] * mults[j]; 136 assert(t_csqrt(CMPLXL(a, b)) == CMPLXL(x, y)); 137 } 138 } 139 --- 24 unchanged lines hidden (view full) --- 164 42.0, 165 -42.0, 166 INFINITY, 167 -INFINITY, 168 }; 169 170 int i; 171 | 132 a = tests[i] * mults[j] * mults[j]; 133 b = tests[i + 1] * mults[j] * mults[j]; 134 x = tests[i + 2] * mults[j]; 135 y = tests[i + 3] * mults[j]; 136 assert(t_csqrt(CMPLXL(a, b)) == CMPLXL(x, y)); 137 } 138 } 139 --- 24 unchanged lines hidden (view full) --- 164 42.0, 165 -42.0, 166 INFINITY, 167 -INFINITY, 168 }; 169 170 int i; 171 |
172 for (i = 0; i < N(vals); i++) { | 172 for (i = 0; i < nitems(vals); i++) { |
173 if (isfinite(vals[i])) { 174 assert_equal(t_csqrt(CMPLXL(-INFINITY, vals[i])), 175 CMPLXL(0.0, copysignl(INFINITY, vals[i]))); 176 assert_equal(t_csqrt(CMPLXL(INFINITY, vals[i])), 177 CMPLXL(INFINITY, copysignl(0.0, vals[i]))); 178 } 179 assert_equal(t_csqrt(CMPLXL(vals[i], INFINITY)), 180 CMPLXL(INFINITY, INFINITY)); --- 115 unchanged lines hidden --- | 173 if (isfinite(vals[i])) { 174 assert_equal(t_csqrt(CMPLXL(-INFINITY, vals[i])), 175 CMPLXL(0.0, copysignl(INFINITY, vals[i]))); 176 assert_equal(t_csqrt(CMPLXL(INFINITY, vals[i])), 177 CMPLXL(INFINITY, copysignl(0.0, vals[i]))); 178 } 179 assert_equal(t_csqrt(CMPLXL(vals[i], INFINITY)), 180 CMPLXL(INFINITY, INFINITY)); --- 115 unchanged lines hidden --- |