1 /* $NetBSD: t_sinh.c,v 1.5 2013/04/09 12:11:04 isaki 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_sinh.c,v 1.5 2013/04/09 12:11:04 isaki Exp $");
43 { -10, -11013.23287470339, 1e4
, },
44 { -2, -3.626860407847019, 1, },
45 { -1, -1.175201193643801, 1, },
46 { -0.05, -0.050020835937655, 1, },
47 { -0.001,-0.001000000166667, 1, },
48 { 0.001, 0.001000000166667, 1, },
49 { 0.05, 0.050020835937655, 1, },
50 { 1, 1.175201193643801, 1, },
51 { 2, 3.626860407847019, 1, },
52 { 10, 11013.23287470339, 1e4
, },
59 ATF_TC_HEAD(sinh_inrange
, tc
)
61 atf_tc_set_md_var(tc
, "descr", "sinh(x) for some values");
64 ATF_TC_BODY(sinh_inrange
, tc
)
72 for (i
= 0; i
< __arraycount(values
); i
++) {
75 eps
= 1e-15 * values
[i
].e
;
77 if (fabs(sinh(x
) - y
) > eps
)
78 atf_tc_fail_nonfatal("sinh(%g) != %g\n", x
, y
);
84 ATF_TC_HEAD(sinh_nan
, tc
)
86 atf_tc_set_md_var(tc
, "descr", "Test sinh(NaN) == NaN");
89 ATF_TC_BODY(sinh_nan
, tc
)
92 const double x
= 0.0L / 0.0L;
94 ATF_CHECK(isnan(x
) != 0);
95 ATF_CHECK(isnan(sinh(x
)) != 0);
100 ATF_TC_HEAD(sinh_inf_neg
, tc
)
102 atf_tc_set_md_var(tc
, "descr", "Test sinh(-Inf) == -Inf");
105 ATF_TC_BODY(sinh_inf_neg
, tc
)
108 const double x
= -1.0L / 0.0L;
111 ATF_CHECK(isinf(y
) != 0);
112 ATF_CHECK(signbit(y
) != 0);
116 ATF_TC(sinh_inf_pos
);
117 ATF_TC_HEAD(sinh_inf_pos
, tc
)
119 atf_tc_set_md_var(tc
, "descr", "Test sinh(+Inf) == +Inf");
122 ATF_TC_BODY(sinh_inf_pos
, tc
)
125 const double x
= 1.0L / 0.0L;
128 ATF_CHECK(isinf(y
) != 0);
129 ATF_CHECK(signbit(y
) == 0);
133 ATF_TC(sinh_zero_neg
);
134 ATF_TC_HEAD(sinh_zero_neg
, tc
)
136 atf_tc_set_md_var(tc
, "descr", "Test sinh(-0.0) == -0.0");
139 ATF_TC_BODY(sinh_zero_neg
, tc
)
142 const double x
= -0.0L;
145 if (fabs(y
) > 0.0 || signbit(y
) == 0)
146 atf_tc_fail_nonfatal("sinh(-0.0) != -0.0");
150 ATF_TC(sinh_zero_pos
);
151 ATF_TC_HEAD(sinh_zero_pos
, tc
)
153 atf_tc_set_md_var(tc
, "descr", "Test sinh(+0.0) == +0.0");
156 ATF_TC_BODY(sinh_zero_pos
, tc
)
159 const double x
= 0.0L;
162 if (fabs(y
) > 0.0 || signbit(y
) != 0)
163 atf_tc_fail_nonfatal("sinh(+0.0) != +0.0");
170 ATF_TC(sinhf_inrange
);
171 ATF_TC_HEAD(sinhf_inrange
, tc
)
173 atf_tc_set_md_var(tc
, "descr", "sinhf(x) for some values");
176 ATF_TC_BODY(sinhf_inrange
, tc
)
184 for (i
= 0; i
< __arraycount(values
); i
++) {
187 eps
= 1e-6 * values
[i
].e
;
189 if (fabsf(sinhf(x
) - y
) > eps
)
190 atf_tc_fail_nonfatal("sinhf(%g) != %g\n", x
, y
);
196 ATF_TC_HEAD(sinhf_nan
, tc
)
198 atf_tc_set_md_var(tc
, "descr", "Test sinhf(NaN) == NaN");
201 ATF_TC_BODY(sinhf_nan
, tc
)
204 const float x
= 0.0L / 0.0L;
206 ATF_CHECK(isnan(x
) != 0);
207 ATF_CHECK(isnan(sinhf(x
)) != 0);
211 ATF_TC(sinhf_inf_neg
);
212 ATF_TC_HEAD(sinhf_inf_neg
, tc
)
214 atf_tc_set_md_var(tc
, "descr", "Test sinhf(-Inf) == -Inf");
217 ATF_TC_BODY(sinhf_inf_neg
, tc
)
220 const float x
= -1.0L / 0.0L;
223 ATF_CHECK(isinf(y
) != 0);
224 ATF_CHECK(signbit(y
) != 0);
228 ATF_TC(sinhf_inf_pos
);
229 ATF_TC_HEAD(sinhf_inf_pos
, tc
)
231 atf_tc_set_md_var(tc
, "descr", "Test sinhf(+Inf) == +Inf");
234 ATF_TC_BODY(sinhf_inf_pos
, tc
)
237 const float x
= 1.0L / 0.0L;
240 ATF_CHECK(isinf(y
) != 0);
241 ATF_CHECK(signbit(y
) == 0);
245 ATF_TC(sinhf_zero_neg
);
246 ATF_TC_HEAD(sinhf_zero_neg
, tc
)
248 atf_tc_set_md_var(tc
, "descr", "Test sinhf(-0.0) == -0.0");
251 ATF_TC_BODY(sinhf_zero_neg
, tc
)
254 const float x
= -0.0L;
257 if (fabsf(y
) > 0.0 || signbit(y
) == 0)
258 atf_tc_fail_nonfatal("sinhf(-0.0) != -0.0");
262 ATF_TC(sinhf_zero_pos
);
263 ATF_TC_HEAD(sinhf_zero_pos
, tc
)
265 atf_tc_set_md_var(tc
, "descr", "Test sinhf(+0.0) == +0.0");
268 ATF_TC_BODY(sinhf_zero_pos
, tc
)
271 const float x
= 0.0L;
274 if (fabsf(y
) > 0.0 || signbit(y
) != 0)
275 atf_tc_fail_nonfatal("sinhf(+0.0) != +0.0");
282 ATF_TP_ADD_TC(tp
, sinh_inrange
);
283 ATF_TP_ADD_TC(tp
, sinh_nan
);
284 ATF_TP_ADD_TC(tp
, sinh_inf_neg
);
285 ATF_TP_ADD_TC(tp
, sinh_inf_pos
);
286 ATF_TP_ADD_TC(tp
, sinh_zero_neg
);
287 ATF_TP_ADD_TC(tp
, sinh_zero_pos
);
289 ATF_TP_ADD_TC(tp
, sinhf_inrange
);
290 ATF_TP_ADD_TC(tp
, sinhf_nan
);
291 ATF_TP_ADD_TC(tp
, sinhf_inf_neg
);
292 ATF_TP_ADD_TC(tp
, sinhf_inf_pos
);
293 ATF_TP_ADD_TC(tp
, sinhf_zero_neg
);
294 ATF_TP_ADD_TC(tp
, sinhf_zero_pos
);
296 return atf_no_error();