1 /* $NetBSD: t_erf.c,v 1.1 2011/09/17 12:00:50 jruoho Exp $ */
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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 $");
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
)
49 const double x
= 0.0L / 0.0L;
51 ATF_CHECK(isnan(erf(x
)) != 0);
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
)
64 const double x
= -1.0L / 0.0L;
67 atf_tc_fail_nonfatal("erf(-Inf) != -1.0");
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
)
80 const double x
= 1.0L / 0.0L;
83 atf_tc_fail_nonfatal("erf(+Inf) != 1.0");
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
)
96 const double x
= -0.0L;
99 if (fabs(y
) > 0.0 || signbit(y
) == 0)
100 atf_tc_fail_nonfatal("erf(-0.0) != -0.0");
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
)
113 const double x
= 0.0L;
116 if (fabs(y
) > 0.0 || signbit(y
) != 0)
117 atf_tc_fail_nonfatal("erf(+0.0) != +0.0");
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
)
133 const float x
= 0.0L / 0.0L;
135 ATF_CHECK(isnan(erff(x
)) != 0);
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
)
148 const float x
= -1.0L / 0.0L;
151 atf_tc_fail_nonfatal("erff(-Inf) != -1.0");
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
)
164 const float x
= 1.0L / 0.0L;
167 atf_tc_fail_nonfatal("erff(+Inf) != 1.0");
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
)
180 const float x
= -0.0L;
183 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
184 atf_tc_fail_nonfatal("erff(-0.0) != -0.0");
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
)
197 const float x
= 0.0L;
200 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
201 atf_tc_fail_nonfatal("erff(+0.0) != +0.0");
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
)
217 const double x
= 0.0L / 0.0L;
219 ATF_CHECK(isnan(erfc(x
)) != 0);
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
)
232 const double x
= -1.0L / 0.0L;
235 atf_tc_fail_nonfatal("erfc(-Inf) != 2.0");
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
)
248 const double x
= 1.0L / 0.0L;
251 if (fabs(y
) > 0.0 || signbit(y
) != 0)
252 atf_tc_fail_nonfatal("erfc(+Inf) != +0.0");
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
)
268 const float x
= 0.0L / 0.0L;
270 ATF_CHECK(isnan(erfcf(x
)) != 0);
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
)
283 const float x
= -1.0L / 0.0L;
286 atf_tc_fail_nonfatal("erfcf(-Inf) != 2.0");
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
)
299 const float x
= 1.0L / 0.0L;
302 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
303 atf_tc_fail_nonfatal("erfcf(+Inf) != +0.0");
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();