tools/llvm: Do not build with symbols
[minix3.git] / tests / lib / libm / t_erf.c
blob514fb56703d0f0728e8a2ad8385a6c419f797ec1
1 /* $NetBSD: t_erf.c,v 1.1 2011/09/17 12:00:50 jruoho Exp $ */
3 /*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jukka Ruohonen.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: t_erf.c,v 1.1 2011/09/17 12:00:50 jruoho Exp $");
34 #include <atf-c.h>
35 #include <math.h>
38 * erf(3)
40 ATF_TC(erf_nan);
41 ATF_TC_HEAD(erf_nan, tc)
43 atf_tc_set_md_var(tc, "descr", "Test erf(NaN) == NaN");
46 ATF_TC_BODY(erf_nan, tc)
48 #ifndef __vax__
49 const double x = 0.0L / 0.0L;
51 ATF_CHECK(isnan(erf(x)) != 0);
52 #endif
55 ATF_TC(erf_inf_neg);
56 ATF_TC_HEAD(erf_inf_neg, tc)
58 atf_tc_set_md_var(tc, "descr", "Test erf(-Inf) == -1.0");
61 ATF_TC_BODY(erf_inf_neg, tc)
63 #ifndef __vax__
64 const double x = -1.0L / 0.0L;
66 if (erf(x) != -1.0)
67 atf_tc_fail_nonfatal("erf(-Inf) != -1.0");
68 #endif
71 ATF_TC(erf_inf_pos);
72 ATF_TC_HEAD(erf_inf_pos, tc)
74 atf_tc_set_md_var(tc, "descr", "Test erf(+Inf) == 1.0");
77 ATF_TC_BODY(erf_inf_pos, tc)
79 #ifndef __vax__
80 const double x = 1.0L / 0.0L;
82 if (erf(x) != 1.0)
83 atf_tc_fail_nonfatal("erf(+Inf) != 1.0");
84 #endif
87 ATF_TC(erf_zero_neg);
88 ATF_TC_HEAD(erf_zero_neg, tc)
90 atf_tc_set_md_var(tc, "descr", "Test erf(-0.0) == -0.0");
93 ATF_TC_BODY(erf_zero_neg, tc)
95 #ifndef __vax__
96 const double x = -0.0L;
97 double y = erf(x);
99 if (fabs(y) > 0.0 || signbit(y) == 0)
100 atf_tc_fail_nonfatal("erf(-0.0) != -0.0");
101 #endif
104 ATF_TC(erf_zero_pos);
105 ATF_TC_HEAD(erf_zero_pos, tc)
107 atf_tc_set_md_var(tc, "descr", "Test erf(+0.0) == +0.0");
110 ATF_TC_BODY(erf_zero_pos, tc)
112 #ifndef __vax__
113 const double x = 0.0L;
114 double y = erf(x);
116 if (fabs(y) > 0.0 || signbit(y) != 0)
117 atf_tc_fail_nonfatal("erf(+0.0) != +0.0");
118 #endif
122 * erff(3)
124 ATF_TC(erff_nan);
125 ATF_TC_HEAD(erff_nan, tc)
127 atf_tc_set_md_var(tc, "descr", "Test erff(NaN) == NaN");
130 ATF_TC_BODY(erff_nan, tc)
132 #ifndef __vax__
133 const float x = 0.0L / 0.0L;
135 ATF_CHECK(isnan(erff(x)) != 0);
136 #endif
139 ATF_TC(erff_inf_neg);
140 ATF_TC_HEAD(erff_inf_neg, tc)
142 atf_tc_set_md_var(tc, "descr", "Test erff(-Inf) == -1.0");
145 ATF_TC_BODY(erff_inf_neg, tc)
147 #ifndef __vax__
148 const float x = -1.0L / 0.0L;
150 if (erff(x) != -1.0)
151 atf_tc_fail_nonfatal("erff(-Inf) != -1.0");
152 #endif
155 ATF_TC(erff_inf_pos);
156 ATF_TC_HEAD(erff_inf_pos, tc)
158 atf_tc_set_md_var(tc, "descr", "Test erff(+Inf) == 1.0");
161 ATF_TC_BODY(erff_inf_pos, tc)
163 #ifndef __vax__
164 const float x = 1.0L / 0.0L;
166 if (erff(x) != 1.0)
167 atf_tc_fail_nonfatal("erff(+Inf) != 1.0");
168 #endif
171 ATF_TC(erff_zero_neg);
172 ATF_TC_HEAD(erff_zero_neg, tc)
174 atf_tc_set_md_var(tc, "descr", "Test erff(-0.0) == -0.0");
177 ATF_TC_BODY(erff_zero_neg, tc)
179 #ifndef __vax__
180 const float x = -0.0L;
181 float y = erff(x);
183 if (fabsf(y) > 0.0 || signbit(y) == 0)
184 atf_tc_fail_nonfatal("erff(-0.0) != -0.0");
185 #endif
188 ATF_TC(erff_zero_pos);
189 ATF_TC_HEAD(erff_zero_pos, tc)
191 atf_tc_set_md_var(tc, "descr", "Test erff(+0.0) == +0.0");
194 ATF_TC_BODY(erff_zero_pos, tc)
196 #ifndef __vax__
197 const float x = 0.0L;
198 float y = erff(x);
200 if (fabsf(y) > 0.0 || signbit(y) != 0)
201 atf_tc_fail_nonfatal("erff(+0.0) != +0.0");
202 #endif
206 * erfc(3)
208 ATF_TC(erfc_nan);
209 ATF_TC_HEAD(erfc_nan, tc)
211 atf_tc_set_md_var(tc, "descr", "Test erfc(NaN) == NaN");
214 ATF_TC_BODY(erfc_nan, tc)
216 #ifndef __vax__
217 const double x = 0.0L / 0.0L;
219 ATF_CHECK(isnan(erfc(x)) != 0);
220 #endif
223 ATF_TC(erfc_inf_neg);
224 ATF_TC_HEAD(erfc_inf_neg, tc)
226 atf_tc_set_md_var(tc, "descr", "Test erfc(-Inf) == 2.0");
229 ATF_TC_BODY(erfc_inf_neg, tc)
231 #ifndef __vax__
232 const double x = -1.0L / 0.0L;
234 if (erfc(x) != 2.0)
235 atf_tc_fail_nonfatal("erfc(-Inf) != 2.0");
236 #endif
239 ATF_TC(erfc_inf_pos);
240 ATF_TC_HEAD(erfc_inf_pos, tc)
242 atf_tc_set_md_var(tc, "descr", "Test erfc(+Inf) == +0.0");
245 ATF_TC_BODY(erfc_inf_pos, tc)
247 #ifndef __vax__
248 const double x = 1.0L / 0.0L;
249 double y = erfc(x);
251 if (fabs(y) > 0.0 || signbit(y) != 0)
252 atf_tc_fail_nonfatal("erfc(+Inf) != +0.0");
253 #endif
257 * erfcf(3)
259 ATF_TC(erfcf_nan);
260 ATF_TC_HEAD(erfcf_nan, tc)
262 atf_tc_set_md_var(tc, "descr", "Test erfcf(NaN) == NaN");
265 ATF_TC_BODY(erfcf_nan, tc)
267 #ifndef __vax__
268 const float x = 0.0L / 0.0L;
270 ATF_CHECK(isnan(erfcf(x)) != 0);
271 #endif
274 ATF_TC(erfcf_inf_neg);
275 ATF_TC_HEAD(erfcf_inf_neg, tc)
277 atf_tc_set_md_var(tc, "descr", "Test erfcf(-Inf) == 2.0");
280 ATF_TC_BODY(erfcf_inf_neg, tc)
282 #ifndef __vax__
283 const float x = -1.0L / 0.0L;
285 if (erfcf(x) != 2.0)
286 atf_tc_fail_nonfatal("erfcf(-Inf) != 2.0");
287 #endif
290 ATF_TC(erfcf_inf_pos);
291 ATF_TC_HEAD(erfcf_inf_pos, tc)
293 atf_tc_set_md_var(tc, "descr", "Test erfcf(+Inf) == +0.0");
296 ATF_TC_BODY(erfcf_inf_pos, tc)
298 #ifndef __vax__
299 const float x = 1.0L / 0.0L;
300 float y = erfcf(x);
302 if (fabsf(y) > 0.0 || signbit(y) != 0)
303 atf_tc_fail_nonfatal("erfcf(+Inf) != +0.0");
304 #endif
307 ATF_TP_ADD_TCS(tp)
310 ATF_TP_ADD_TC(tp, erf_nan);
311 ATF_TP_ADD_TC(tp, erf_inf_neg);
312 ATF_TP_ADD_TC(tp, erf_inf_pos);
313 ATF_TP_ADD_TC(tp, erf_zero_neg);
314 ATF_TP_ADD_TC(tp, erf_zero_pos);
316 ATF_TP_ADD_TC(tp, erff_nan);
317 ATF_TP_ADD_TC(tp, erff_inf_neg);
318 ATF_TP_ADD_TC(tp, erff_inf_pos);
319 ATF_TP_ADD_TC(tp, erff_zero_neg);
320 ATF_TP_ADD_TC(tp, erff_zero_pos);
322 ATF_TP_ADD_TC(tp, erfc_nan);
323 ATF_TP_ADD_TC(tp, erfc_inf_neg);
324 ATF_TP_ADD_TC(tp, erfc_inf_pos);
326 ATF_TP_ADD_TC(tp, erfcf_nan);
327 ATF_TP_ADD_TC(tp, erfcf_inf_neg);
328 ATF_TP_ADD_TC(tp, erfcf_inf_pos);
330 return atf_no_error();