1 /* $NetBSD: t_erf.c,v 1.2 2014/03/03 10:39:08 martin 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.2 2014/03/03 10:39:08 martin 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
)
48 const double x
= 0.0L / 0.0L;
50 ATF_CHECK(isnan(erf(x
)) != 0);
54 ATF_TC_HEAD(erf_inf_neg
, tc
)
56 atf_tc_set_md_var(tc
, "descr", "Test erf(-Inf) == -1.0");
59 ATF_TC_BODY(erf_inf_neg
, tc
)
61 const double x
= -1.0L / 0.0L;
64 atf_tc_fail_nonfatal("erf(-Inf) != -1.0");
68 ATF_TC_HEAD(erf_inf_pos
, tc
)
70 atf_tc_set_md_var(tc
, "descr", "Test erf(+Inf) == 1.0");
73 ATF_TC_BODY(erf_inf_pos
, tc
)
75 const double x
= 1.0L / 0.0L;
78 atf_tc_fail_nonfatal("erf(+Inf) != 1.0");
82 ATF_TC_HEAD(erf_zero_neg
, tc
)
84 atf_tc_set_md_var(tc
, "descr", "Test erf(-0.0) == -0.0");
87 ATF_TC_BODY(erf_zero_neg
, tc
)
89 const double x
= -0.0L;
92 if (fabs(y
) > 0.0 || signbit(y
) == 0)
93 atf_tc_fail_nonfatal("erf(-0.0) != -0.0");
97 ATF_TC_HEAD(erf_zero_pos
, tc
)
99 atf_tc_set_md_var(tc
, "descr", "Test erf(+0.0) == +0.0");
102 ATF_TC_BODY(erf_zero_pos
, tc
)
104 const double x
= 0.0L;
107 if (fabs(y
) > 0.0 || signbit(y
) != 0)
108 atf_tc_fail_nonfatal("erf(+0.0) != +0.0");
115 ATF_TC_HEAD(erff_nan
, tc
)
117 atf_tc_set_md_var(tc
, "descr", "Test erff(NaN) == NaN");
120 ATF_TC_BODY(erff_nan
, tc
)
122 const float x
= 0.0L / 0.0L;
124 ATF_CHECK(isnan(erff(x
)) != 0);
127 ATF_TC(erff_inf_neg
);
128 ATF_TC_HEAD(erff_inf_neg
, tc
)
130 atf_tc_set_md_var(tc
, "descr", "Test erff(-Inf) == -1.0");
133 ATF_TC_BODY(erff_inf_neg
, tc
)
135 const float x
= -1.0L / 0.0L;
138 atf_tc_fail_nonfatal("erff(-Inf) != -1.0");
141 ATF_TC(erff_inf_pos
);
142 ATF_TC_HEAD(erff_inf_pos
, tc
)
144 atf_tc_set_md_var(tc
, "descr", "Test erff(+Inf) == 1.0");
147 ATF_TC_BODY(erff_inf_pos
, tc
)
149 const float x
= 1.0L / 0.0L;
152 atf_tc_fail_nonfatal("erff(+Inf) != 1.0");
155 ATF_TC(erff_zero_neg
);
156 ATF_TC_HEAD(erff_zero_neg
, tc
)
158 atf_tc_set_md_var(tc
, "descr", "Test erff(-0.0) == -0.0");
161 ATF_TC_BODY(erff_zero_neg
, tc
)
163 const float x
= -0.0L;
166 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
167 atf_tc_fail_nonfatal("erff(-0.0) != -0.0");
170 ATF_TC(erff_zero_pos
);
171 ATF_TC_HEAD(erff_zero_pos
, tc
)
173 atf_tc_set_md_var(tc
, "descr", "Test erff(+0.0) == +0.0");
176 ATF_TC_BODY(erff_zero_pos
, tc
)
178 const float x
= 0.0L;
181 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
182 atf_tc_fail_nonfatal("erff(+0.0) != +0.0");
189 ATF_TC_HEAD(erfc_nan
, tc
)
191 atf_tc_set_md_var(tc
, "descr", "Test erfc(NaN) == NaN");
194 ATF_TC_BODY(erfc_nan
, tc
)
196 const double x
= 0.0L / 0.0L;
198 ATF_CHECK(isnan(erfc(x
)) != 0);
201 ATF_TC(erfc_inf_neg
);
202 ATF_TC_HEAD(erfc_inf_neg
, tc
)
204 atf_tc_set_md_var(tc
, "descr", "Test erfc(-Inf) == 2.0");
207 ATF_TC_BODY(erfc_inf_neg
, tc
)
209 const double x
= -1.0L / 0.0L;
212 atf_tc_fail_nonfatal("erfc(-Inf) != 2.0");
215 ATF_TC(erfc_inf_pos
);
216 ATF_TC_HEAD(erfc_inf_pos
, tc
)
218 atf_tc_set_md_var(tc
, "descr", "Test erfc(+Inf) == +0.0");
221 ATF_TC_BODY(erfc_inf_pos
, tc
)
223 const double x
= 1.0L / 0.0L;
226 if (fabs(y
) > 0.0 || signbit(y
) != 0)
227 atf_tc_fail_nonfatal("erfc(+Inf) != +0.0");
234 ATF_TC_HEAD(erfcf_nan
, tc
)
236 atf_tc_set_md_var(tc
, "descr", "Test erfcf(NaN) == NaN");
239 ATF_TC_BODY(erfcf_nan
, tc
)
241 const float x
= 0.0L / 0.0L;
243 ATF_CHECK(isnan(erfcf(x
)) != 0);
246 ATF_TC(erfcf_inf_neg
);
247 ATF_TC_HEAD(erfcf_inf_neg
, tc
)
249 atf_tc_set_md_var(tc
, "descr", "Test erfcf(-Inf) == 2.0");
252 ATF_TC_BODY(erfcf_inf_neg
, tc
)
254 const float x
= -1.0L / 0.0L;
257 atf_tc_fail_nonfatal("erfcf(-Inf) != 2.0");
260 ATF_TC(erfcf_inf_pos
);
261 ATF_TC_HEAD(erfcf_inf_pos
, tc
)
263 atf_tc_set_md_var(tc
, "descr", "Test erfcf(+Inf) == +0.0");
266 ATF_TC_BODY(erfcf_inf_pos
, tc
)
268 const float x
= 1.0L / 0.0L;
271 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
272 atf_tc_fail_nonfatal("erfcf(+Inf) != +0.0");
278 ATF_TP_ADD_TC(tp
, erf_nan
);
279 ATF_TP_ADD_TC(tp
, erf_inf_neg
);
280 ATF_TP_ADD_TC(tp
, erf_inf_pos
);
281 ATF_TP_ADD_TC(tp
, erf_zero_neg
);
282 ATF_TP_ADD_TC(tp
, erf_zero_pos
);
284 ATF_TP_ADD_TC(tp
, erff_nan
);
285 ATF_TP_ADD_TC(tp
, erff_inf_neg
);
286 ATF_TP_ADD_TC(tp
, erff_inf_pos
);
287 ATF_TP_ADD_TC(tp
, erff_zero_neg
);
288 ATF_TP_ADD_TC(tp
, erff_zero_pos
);
290 ATF_TP_ADD_TC(tp
, erfc_nan
);
291 ATF_TP_ADD_TC(tp
, erfc_inf_neg
);
292 ATF_TP_ADD_TC(tp
, erfc_inf_pos
);
294 ATF_TP_ADD_TC(tp
, erfcf_nan
);
295 ATF_TP_ADD_TC(tp
, erfcf_inf_neg
);
296 ATF_TP_ADD_TC(tp
, erfcf_inf_pos
);
298 return atf_no_error();