xref: /openbsd-src/regress/lib/libm/msun/cexp_test.c (revision 498c7b5e98c82ca5a0055f676f2a6e4214e2d9a8)
1*498c7b5eSderaadt /*	$OpenBSD: cexp_test.c,v 1.3 2021/12/13 18:04:28 deraadt Exp $	*/
2c36e572eSmbuhl /*-
3c36e572eSmbuhl  * Copyright (c) 2008-2011 David Schultz <das@FreeBSD.org>
4c36e572eSmbuhl  * All rights reserved.
5c36e572eSmbuhl  *
6c36e572eSmbuhl  * Redistribution and use in source and binary forms, with or without
7c36e572eSmbuhl  * modification, are permitted provided that the following conditions
8c36e572eSmbuhl  * are met:
9c36e572eSmbuhl  * 1. Redistributions of source code must retain the above copyright
10c36e572eSmbuhl  *    notice, this list of conditions and the following disclaimer.
11c36e572eSmbuhl  * 2. Redistributions in binary form must reproduce the above copyright
12c36e572eSmbuhl  *    notice, this list of conditions and the following disclaimer in the
13c36e572eSmbuhl  *    documentation and/or other materials provided with the distribution.
14c36e572eSmbuhl  *
15c36e572eSmbuhl  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16c36e572eSmbuhl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17c36e572eSmbuhl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18c36e572eSmbuhl  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19c36e572eSmbuhl  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20c36e572eSmbuhl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21c36e572eSmbuhl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22c36e572eSmbuhl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23c36e572eSmbuhl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24c36e572eSmbuhl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25c36e572eSmbuhl  * SUCH DAMAGE.
26c36e572eSmbuhl  */
27c36e572eSmbuhl 
28c36e572eSmbuhl #include "macros.h"
29c36e572eSmbuhl 
30c36e572eSmbuhl /*
31c36e572eSmbuhl  * Tests for corner cases in cexp*().
32c36e572eSmbuhl  */
33c36e572eSmbuhl 
3449a6e16fSderaadt #include <sys/types.h>
35c36e572eSmbuhl 
36c36e572eSmbuhl #include <complex.h>
37c36e572eSmbuhl #include <fenv.h>
38c36e572eSmbuhl #include <float.h>
39c36e572eSmbuhl #include <math.h>
40c36e572eSmbuhl #include <stdio.h>
41c36e572eSmbuhl 
42c36e572eSmbuhl #include "test-utils.h"
43c36e572eSmbuhl 
44c36e572eSmbuhl #pragma STDC FENV_ACCESS	ON
45c36e572eSmbuhl #pragma	STDC CX_LIMITED_RANGE	OFF
46c36e572eSmbuhl 
47c36e572eSmbuhl /*
48c36e572eSmbuhl  * Test that a function returns the correct value and sets the
49c36e572eSmbuhl  * exception flags correctly. The exceptmask specifies which
50c36e572eSmbuhl  * exceptions we should check. We need to be lenient for several
51c36e572eSmbuhl  * reasons, but mainly because on some architectures it's impossible
52c36e572eSmbuhl  * to raise FE_OVERFLOW without raising FE_INEXACT. In some cases,
53c36e572eSmbuhl  * whether cexp() raises an invalid exception is unspecified.
54c36e572eSmbuhl  *
55c36e572eSmbuhl  * These are macros instead of functions so that assert provides more
56c36e572eSmbuhl  * meaningful error messages.
57c36e572eSmbuhl  *
58c36e572eSmbuhl  * XXX The volatile here is to avoid gcc's bogus constant folding and work
59c36e572eSmbuhl  *     around the lack of support for the FENV_ACCESS pragma.
60c36e572eSmbuhl  */
61c36e572eSmbuhl #define	test_t(type, func, z, result, exceptmask, excepts, checksign)	\
62c36e572eSmbuhl do {									\
63c36e572eSmbuhl 	volatile long double complex _d = z;				\
64c36e572eSmbuhl 	volatile type complex _r = result;				\
65c36e572eSmbuhl 	ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));		\
66c36e572eSmbuhl 	CHECK_CFPEQUAL_CS((func)(_d), (_r), (checksign));		\
67c36e572eSmbuhl 	CHECK_FP_EXCEPTIONS_MSG(excepts, exceptmask, "for %s(%s)",	\
68c36e572eSmbuhl 	    #func, #z);							\
69c36e572eSmbuhl } while (0)
70c36e572eSmbuhl 
71c36e572eSmbuhl #define	test(func, z, result, exceptmask, excepts, checksign)		\
72c36e572eSmbuhl 	test_t(double, func, z, result, exceptmask, excepts, checksign)
73c36e572eSmbuhl 
74c36e572eSmbuhl #define	test_f(func, z, result, exceptmask, excepts, checksign)		\
75c36e572eSmbuhl 	test_t(float, func, z, result, exceptmask, excepts, checksign)
76c36e572eSmbuhl 
77c36e572eSmbuhl #define	test_l(func, z, result, exceptmask, excepts, checksign)		\
78c36e572eSmbuhl 	test_t(long double, func, z, result, exceptmask, excepts,	\
79c36e572eSmbuhl 	    checksign)
80c36e572eSmbuhl /* Test within a given tolerance. */
81c36e572eSmbuhl #define	test_tol(func, z, result, tol)	do {			\
82c36e572eSmbuhl 	CHECK_CFPEQUAL_TOL((func)(z), (result), (tol),		\
83c36e572eSmbuhl 	    FPE_ABS_ZERO | CS_BOTH);				\
84c36e572eSmbuhl } while (0)
85c36e572eSmbuhl 
86c36e572eSmbuhl /* Test all the functions that compute cexp(x). */
87c36e572eSmbuhl #define	testall(x, result, exceptmask, excepts, checksign)	do {	\
88c36e572eSmbuhl 	test(cexp, x, result, exceptmask, excepts, checksign);		\
89c36e572eSmbuhl 	test_f(cexpf, x, result, exceptmask, excepts, checksign);	\
90c36e572eSmbuhl 	test_l(cexpl, x, result, exceptmask, excepts, checksign);	\
91c36e572eSmbuhl } while (0)
92c36e572eSmbuhl 
93c36e572eSmbuhl /*
94c36e572eSmbuhl  * Test all the functions that compute cexp(x), within a given tolerance.
95c36e572eSmbuhl  * The tolerance is specified in ulps.
96c36e572eSmbuhl  */
97c36e572eSmbuhl #define	testall_tol(x, result, tol)				do {	\
98c36e572eSmbuhl 	test_tol(cexp, x, result, tol * DBL_ULP());			\
99c36e572eSmbuhl 	test_tol(cexpf, x, result, tol * FLT_ULP());			\
100c36e572eSmbuhl } while (0)
101c36e572eSmbuhl 
102c36e572eSmbuhl /* Various finite non-zero numbers to test. */
103c36e572eSmbuhl static const float finites[] =
104c36e572eSmbuhl { -42.0e20, -1.0, -1.0e-10, -0.0, 0.0, 1.0e-10, 1.0, 42.0e20 };
105c36e572eSmbuhl 
106c36e572eSmbuhl 
107c36e572eSmbuhl /* Tests for 0 */
108c36e572eSmbuhl ATF_TC_WITHOUT_HEAD(zero);
ATF_TC_BODY(zero,tc)109c36e572eSmbuhl ATF_TC_BODY(zero, tc)
110c36e572eSmbuhl {
111c36e572eSmbuhl 
112c36e572eSmbuhl 	/* cexp(0) = 1, no exceptions raised */
113c36e572eSmbuhl 	testall(0.0, 1.0, ALL_STD_EXCEPT, 0, 1);
114c36e572eSmbuhl 	testall(-0.0, 1.0, ALL_STD_EXCEPT, 0, 1);
115c36e572eSmbuhl 	testall(CMPLXL(0.0, -0.0), CMPLXL(1.0, -0.0), ALL_STD_EXCEPT, 0, 1);
116c36e572eSmbuhl 	testall(CMPLXL(-0.0, -0.0), CMPLXL(1.0, -0.0), ALL_STD_EXCEPT, 0, 1);
117c36e572eSmbuhl }
118c36e572eSmbuhl 
119c36e572eSmbuhl /*
120c36e572eSmbuhl  * Tests for NaN.  The signs of the results are indeterminate unless the
121c36e572eSmbuhl  * imaginary part is 0.
122c36e572eSmbuhl  */
123c36e572eSmbuhl ATF_TC_WITHOUT_HEAD(nan);
ATF_TC_BODY(nan,tc)124c36e572eSmbuhl ATF_TC_BODY(nan, tc)
125c36e572eSmbuhl {
126c36e572eSmbuhl 	unsigned i;
127c36e572eSmbuhl 
128c36e572eSmbuhl 	/* cexp(x + NaNi) = NaN + NaNi and optionally raises invalid */
129c36e572eSmbuhl 	/* cexp(NaN + yi) = NaN + NaNi and optionally raises invalid (|y|>0) */
130c36e572eSmbuhl 	for (i = 0; i < nitems(finites); i++) {
131c36e572eSmbuhl 		testall(CMPLXL(finites[i], NAN), CMPLXL(NAN, NAN),
132c36e572eSmbuhl 			ALL_STD_EXCEPT & ~FE_INVALID, 0, 0);
133c36e572eSmbuhl 		if (finites[i] == 0.0)
134c36e572eSmbuhl 			continue;
135c36e572eSmbuhl #ifndef __OpenBSD__
136c36e572eSmbuhl 		/* XXX FE_INEXACT shouldn't be raised here */
137c36e572eSmbuhl 		testall(CMPLXL(NAN, finites[i]), CMPLXL(NAN, NAN),
138c36e572eSmbuhl 			ALL_STD_EXCEPT & ~(FE_INVALID | FE_INEXACT), 0, 0);
139c36e572eSmbuhl #else
140c36e572eSmbuhl 		testall(CMPLXL(NAN, finites[i]), CMPLXL(NAN, NAN),
141c36e572eSmbuhl 			ALL_STD_EXCEPT & ~(FE_INVALID), 0, 0);
142c36e572eSmbuhl #endif
143c36e572eSmbuhl 	}
144c36e572eSmbuhl 
145c36e572eSmbuhl 	/* cexp(NaN +- 0i) = NaN +- 0i */
146c36e572eSmbuhl 	testall(CMPLXL(NAN, 0.0), CMPLXL(NAN, 0.0), ALL_STD_EXCEPT, 0, 1);
147c36e572eSmbuhl 	testall(CMPLXL(NAN, -0.0), CMPLXL(NAN, -0.0), ALL_STD_EXCEPT, 0, 1);
148c36e572eSmbuhl 
149c36e572eSmbuhl 	/* cexp(inf + NaN i) = inf + nan i */
150c36e572eSmbuhl 	testall(CMPLXL(INFINITY, NAN), CMPLXL(INFINITY, NAN),
151c36e572eSmbuhl 		ALL_STD_EXCEPT, 0, 0);
152c36e572eSmbuhl 	/* cexp(-inf + NaN i) = 0 */
153c36e572eSmbuhl 	testall(CMPLXL(-INFINITY, NAN), CMPLXL(0.0, 0.0),
154c36e572eSmbuhl 		ALL_STD_EXCEPT, 0, 0);
155c36e572eSmbuhl 	/* cexp(NaN + NaN i) = NaN + NaN i */
156c36e572eSmbuhl 	testall(CMPLXL(NAN, NAN), CMPLXL(NAN, NAN),
157c36e572eSmbuhl 		ALL_STD_EXCEPT, 0, 0);
158c36e572eSmbuhl }
159c36e572eSmbuhl 
160c36e572eSmbuhl ATF_TC_WITHOUT_HEAD(inf);
ATF_TC_BODY(inf,tc)161c36e572eSmbuhl ATF_TC_BODY(inf, tc)
162c36e572eSmbuhl {
163c36e572eSmbuhl 	unsigned i;
164c36e572eSmbuhl 
165c36e572eSmbuhl 	/* cexp(x + inf i) = NaN + NaNi and raises invalid */
166c36e572eSmbuhl 	for (i = 0; i < nitems(finites); i++) {
167c36e572eSmbuhl 		testall(CMPLXL(finites[i], INFINITY), CMPLXL(NAN, NAN),
168c36e572eSmbuhl 			ALL_STD_EXCEPT, FE_INVALID, 1);
169c36e572eSmbuhl 	}
170c36e572eSmbuhl 	/* cexp(-inf + yi) = 0 * (cos(y) + sin(y)i) */
171c36e572eSmbuhl 	/* XXX shouldn't raise an inexact exception */
172c36e572eSmbuhl 	testall(CMPLXL(-INFINITY, M_PI_4), CMPLXL(0.0, 0.0),
173c36e572eSmbuhl 		ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
174c36e572eSmbuhl 	testall(CMPLXL(-INFINITY, 3 * M_PI_4), CMPLXL(-0.0, 0.0),
175c36e572eSmbuhl 		ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
176c36e572eSmbuhl 	testall(CMPLXL(-INFINITY, 5 * M_PI_4), CMPLXL(-0.0, -0.0),
177c36e572eSmbuhl 		ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
178c36e572eSmbuhl 	testall(CMPLXL(-INFINITY, 7 * M_PI_4), CMPLXL(0.0, -0.0),
179c36e572eSmbuhl 		ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
180c36e572eSmbuhl 	testall(CMPLXL(-INFINITY, 0.0), CMPLXL(0.0, 0.0),
181c36e572eSmbuhl 		ALL_STD_EXCEPT, 0, 1);
182c36e572eSmbuhl 	testall(CMPLXL(-INFINITY, -0.0), CMPLXL(0.0, -0.0),
183c36e572eSmbuhl 		ALL_STD_EXCEPT, 0, 1);
184c36e572eSmbuhl 	/* cexp(inf + yi) = inf * (cos(y) + sin(y)i) (except y=0) */
185c36e572eSmbuhl 	/* XXX shouldn't raise an inexact exception */
186c36e572eSmbuhl 	testall(CMPLXL(INFINITY, M_PI_4), CMPLXL(INFINITY, INFINITY),
187c36e572eSmbuhl 		ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
188c36e572eSmbuhl 	testall(CMPLXL(INFINITY, 3 * M_PI_4), CMPLXL(-INFINITY, INFINITY),
189c36e572eSmbuhl 		ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
190c36e572eSmbuhl 	testall(CMPLXL(INFINITY, 5 * M_PI_4), CMPLXL(-INFINITY, -INFINITY),
191c36e572eSmbuhl 		ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
192c36e572eSmbuhl 	testall(CMPLXL(INFINITY, 7 * M_PI_4), CMPLXL(INFINITY, -INFINITY),
193c36e572eSmbuhl 		ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
194c36e572eSmbuhl 	/* cexp(inf + 0i) = inf + 0i */
195c36e572eSmbuhl 	testall(CMPLXL(INFINITY, 0.0), CMPLXL(INFINITY, 0.0),
196c36e572eSmbuhl 		ALL_STD_EXCEPT, 0, 1);
197c36e572eSmbuhl 	testall(CMPLXL(INFINITY, -0.0), CMPLXL(INFINITY, -0.0),
198c36e572eSmbuhl 		ALL_STD_EXCEPT, 0, 1);
199c36e572eSmbuhl }
200c36e572eSmbuhl 
201c36e572eSmbuhl ATF_TC_WITHOUT_HEAD(reals);
ATF_TC_BODY(reals,tc)202c36e572eSmbuhl ATF_TC_BODY(reals, tc)
203c36e572eSmbuhl {
204c36e572eSmbuhl 	unsigned i;
205c36e572eSmbuhl 
206c36e572eSmbuhl 	for (i = 0; i < nitems(finites); i++) {
207c36e572eSmbuhl 		/* XXX could check exceptions more meticulously */
208c36e572eSmbuhl 		test(cexp, CMPLXL(finites[i], 0.0),
209c36e572eSmbuhl 		     CMPLXL(exp(finites[i]), 0.0),
210c36e572eSmbuhl 		     FE_INVALID | FE_DIVBYZERO, 0, 1);
211c36e572eSmbuhl 		test(cexp, CMPLXL(finites[i], -0.0),
212c36e572eSmbuhl 		     CMPLXL(exp(finites[i]), -0.0),
213c36e572eSmbuhl 		     FE_INVALID | FE_DIVBYZERO, 0, 1);
214c36e572eSmbuhl 		test_f(cexpf, CMPLXL(finites[i], 0.0),
215c36e572eSmbuhl 		     CMPLXL(expf(finites[i]), 0.0),
216c36e572eSmbuhl 		     FE_INVALID | FE_DIVBYZERO, 0, 1);
217c36e572eSmbuhl 		test_f(cexpf, CMPLXL(finites[i], -0.0),
218c36e572eSmbuhl 		     CMPLXL(expf(finites[i]), -0.0),
219c36e572eSmbuhl 		     FE_INVALID | FE_DIVBYZERO, 0, 1);
220c36e572eSmbuhl 	}
221c36e572eSmbuhl }
222c36e572eSmbuhl 
223c36e572eSmbuhl ATF_TC_WITHOUT_HEAD(imaginaries);
ATF_TC_BODY(imaginaries,tc)224c36e572eSmbuhl ATF_TC_BODY(imaginaries, tc)
225c36e572eSmbuhl {
226c36e572eSmbuhl 	unsigned i;
227c36e572eSmbuhl 
228c36e572eSmbuhl 	for (i = 0; i < nitems(finites); i++) {
229c36e572eSmbuhl 		test(cexp, CMPLXL(0.0, finites[i]),
230c36e572eSmbuhl 		     CMPLXL(cos(finites[i]), sin(finites[i])),
231c36e572eSmbuhl 		     ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
232c36e572eSmbuhl 		test(cexp, CMPLXL(-0.0, finites[i]),
233c36e572eSmbuhl 		     CMPLXL(cos(finites[i]), sin(finites[i])),
234c36e572eSmbuhl 		     ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
235c36e572eSmbuhl 		test_f(cexpf, CMPLXL(0.0, finites[i]),
236c36e572eSmbuhl 		     CMPLXL(cosf(finites[i]), sinf(finites[i])),
237c36e572eSmbuhl 		     ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
238c36e572eSmbuhl 		test_f(cexpf, CMPLXL(-0.0, finites[i]),
239c36e572eSmbuhl 		     CMPLXL(cosf(finites[i]), sinf(finites[i])),
240c36e572eSmbuhl 		     ALL_STD_EXCEPT & ~FE_INEXACT, 0, 1);
241c36e572eSmbuhl 	}
242c36e572eSmbuhl }
243c36e572eSmbuhl 
244c36e572eSmbuhl ATF_TC_WITHOUT_HEAD(small);
ATF_TC_BODY(small,tc)245c36e572eSmbuhl ATF_TC_BODY(small, tc)
246c36e572eSmbuhl {
247c36e572eSmbuhl 	static const double tests[] = {
248c36e572eSmbuhl 	     /* csqrt(a + bI) = x + yI */
249c36e572eSmbuhl 	     /* a	b	x			y */
250c36e572eSmbuhl 		 1.0,	M_PI_4,	M_SQRT2 * 0.5 * M_E,	M_SQRT2 * 0.5 * M_E,
251c36e572eSmbuhl 		-1.0,	M_PI_4,	M_SQRT2 * 0.5 / M_E,	M_SQRT2 * 0.5 / M_E,
252c36e572eSmbuhl 		 2.0,	M_PI_2,	0.0,			M_E * M_E,
253c36e572eSmbuhl 		 M_LN2,	M_PI,	-2.0,			0.0,
254c36e572eSmbuhl 	};
255c36e572eSmbuhl 	double a, b;
256c36e572eSmbuhl 	double x, y;
257c36e572eSmbuhl 	unsigned i;
258c36e572eSmbuhl 
259c36e572eSmbuhl 	for (i = 0; i < nitems(tests); i += 4) {
260c36e572eSmbuhl 		a = tests[i];
261c36e572eSmbuhl 		b = tests[i + 1];
262c36e572eSmbuhl 		x = tests[i + 2];
263c36e572eSmbuhl 		y = tests[i + 3];
264c36e572eSmbuhl 		test_tol(cexp, CMPLXL(a, b), CMPLXL(x, y), 3 * DBL_ULP());
265c36e572eSmbuhl 
266c36e572eSmbuhl 		/* float doesn't have enough precision to pass these tests */
267c36e572eSmbuhl 		if (x == 0 || y == 0)
268c36e572eSmbuhl 			continue;
269c36e572eSmbuhl 		test_tol(cexpf, CMPLXL(a, b), CMPLXL(x, y), 1 * FLT_ULP());
270c36e572eSmbuhl         }
271c36e572eSmbuhl }
272c36e572eSmbuhl 
273c36e572eSmbuhl /* Test inputs with a real part r that would overflow exp(r). */
274c36e572eSmbuhl ATF_TC_WITHOUT_HEAD(large);
ATF_TC_BODY(large,tc)275c36e572eSmbuhl ATF_TC_BODY(large, tc)
276c36e572eSmbuhl {
277c36e572eSmbuhl 
278c36e572eSmbuhl 	test_tol(cexp, CMPLXL(709.79, 0x1p-1074),
279c36e572eSmbuhl 		 CMPLXL(INFINITY, 8.94674309915433533273e-16), DBL_ULP());
280c36e572eSmbuhl 	test_tol(cexp, CMPLXL(1000, 0x1p-1074),
281c36e572eSmbuhl 		 CMPLXL(INFINITY, 9.73344457300016401328e+110), DBL_ULP());
282c36e572eSmbuhl 	test_tol(cexp, CMPLXL(1400, 0x1p-1074),
283c36e572eSmbuhl 		 CMPLXL(INFINITY, 5.08228858149196559681e+284), DBL_ULP());
284c36e572eSmbuhl 	test_tol(cexp, CMPLXL(900, 0x1.23456789abcdep-1020),
285c36e572eSmbuhl 		 CMPLXL(INFINITY, 7.42156649354218408074e+83), DBL_ULP());
286c36e572eSmbuhl 	test_tol(cexp, CMPLXL(1300, 0x1.23456789abcdep-1020),
287c36e572eSmbuhl 		 CMPLXL(INFINITY, 3.87514844965996756704e+257), DBL_ULP());
288c36e572eSmbuhl 
289c36e572eSmbuhl 	test_tol(cexpf, CMPLXL(88.73, 0x1p-149),
290c36e572eSmbuhl 		 CMPLXL(INFINITY, 4.80265603e-07), 2 * FLT_ULP());
291c36e572eSmbuhl 	test_tol(cexpf, CMPLXL(90, 0x1p-149),
292c36e572eSmbuhl 		 CMPLXL(INFINITY, 1.7101492622e-06f), 2 * FLT_ULP());
293c36e572eSmbuhl 	test_tol(cexpf, CMPLXL(192, 0x1p-149),
294c36e572eSmbuhl 		 CMPLXL(INFINITY, 3.396809344e+38f), 2 * FLT_ULP());
295c36e572eSmbuhl 	test_tol(cexpf, CMPLXL(120, 0x1.234568p-120),
296c36e572eSmbuhl 		 CMPLXL(INFINITY, 1.1163382522e+16f), 2 * FLT_ULP());
297c36e572eSmbuhl 	test_tol(cexpf, CMPLXL(170, 0x1.234568p-120),
298c36e572eSmbuhl 		 CMPLXL(INFINITY, 5.7878851079e+37f), 2 * FLT_ULP());
299c36e572eSmbuhl }
300c36e572eSmbuhl 
ATF_TP_ADD_TCS(tp)301c36e572eSmbuhl ATF_TP_ADD_TCS(tp)
302c36e572eSmbuhl {
303c36e572eSmbuhl 	ATF_TP_ADD_TC(tp, zero);
304c36e572eSmbuhl 	ATF_TP_ADD_TC(tp, nan);
305c36e572eSmbuhl 	ATF_TP_ADD_TC(tp, inf);
306c36e572eSmbuhl 	ATF_TP_ADD_TC(tp, reals);
307c36e572eSmbuhl 	ATF_TP_ADD_TC(tp, imaginaries);
308c36e572eSmbuhl 	ATF_TP_ADD_TC(tp, small);
309c36e572eSmbuhl 	ATF_TP_ADD_TC(tp, large);
310c36e572eSmbuhl 
311c36e572eSmbuhl 	return (atf_no_error());
312c36e572eSmbuhl }
313