Remove building with NOCRYPTO option
[minix.git] / tests / lib / libm / t_sinh.c
blobd935f0ea7ffb08c0a3f6cb5e73cfbbc4f7545101
1 /* $NetBSD: t_sinh.c,v 1.6 2014/03/03 10:39:08 martin 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_sinh.c,v 1.6 2014/03/03 10:39:08 martin Exp $");
34 #include <atf-c.h>
35 #include <math.h>
36 #include <stdio.h>
38 static const struct {
39 double x;
40 double y;
41 double e;
42 } values[] = {
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, },
56 * sinh(3)
58 ATF_TC(sinh_inrange);
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)
66 double eps;
67 double x;
68 double y;
69 size_t i;
71 for (i = 0; i < __arraycount(values); i++) {
72 x = values[i].x;
73 y = values[i].y;
74 eps = 1e-15 * values[i].e;
76 if (fabs(sinh(x) - y) > eps)
77 atf_tc_fail_nonfatal("sinh(%g) != %g\n", x, y);
81 ATF_TC(sinh_nan);
82 ATF_TC_HEAD(sinh_nan, tc)
84 atf_tc_set_md_var(tc, "descr", "Test sinh(NaN) == NaN");
87 ATF_TC_BODY(sinh_nan, tc)
89 const double x = 0.0L / 0.0L;
91 ATF_CHECK(isnan(x) != 0);
92 ATF_CHECK(isnan(sinh(x)) != 0);
95 ATF_TC(sinh_inf_neg);
96 ATF_TC_HEAD(sinh_inf_neg, tc)
98 atf_tc_set_md_var(tc, "descr", "Test sinh(-Inf) == -Inf");
101 ATF_TC_BODY(sinh_inf_neg, tc)
103 const double x = -1.0L / 0.0L;
104 double y = sinh(x);
106 ATF_CHECK(isinf(y) != 0);
107 ATF_CHECK(signbit(y) != 0);
110 ATF_TC(sinh_inf_pos);
111 ATF_TC_HEAD(sinh_inf_pos, tc)
113 atf_tc_set_md_var(tc, "descr", "Test sinh(+Inf) == +Inf");
116 ATF_TC_BODY(sinh_inf_pos, tc)
118 const double x = 1.0L / 0.0L;
119 double y = sinh(x);
121 ATF_CHECK(isinf(y) != 0);
122 ATF_CHECK(signbit(y) == 0);
125 ATF_TC(sinh_zero_neg);
126 ATF_TC_HEAD(sinh_zero_neg, tc)
128 atf_tc_set_md_var(tc, "descr", "Test sinh(-0.0) == -0.0");
131 ATF_TC_BODY(sinh_zero_neg, tc)
133 const double x = -0.0L;
134 double y = sinh(x);
136 if (fabs(y) > 0.0 || signbit(y) == 0)
137 atf_tc_fail_nonfatal("sinh(-0.0) != -0.0");
140 ATF_TC(sinh_zero_pos);
141 ATF_TC_HEAD(sinh_zero_pos, tc)
143 atf_tc_set_md_var(tc, "descr", "Test sinh(+0.0) == +0.0");
146 ATF_TC_BODY(sinh_zero_pos, tc)
148 const double x = 0.0L;
149 double y = sinh(x);
151 if (fabs(y) > 0.0 || signbit(y) != 0)
152 atf_tc_fail_nonfatal("sinh(+0.0) != +0.0");
156 * sinhf(3)
158 ATF_TC(sinhf_inrange);
159 ATF_TC_HEAD(sinhf_inrange, tc)
161 atf_tc_set_md_var(tc, "descr", "sinhf(x) for some values");
164 ATF_TC_BODY(sinhf_inrange, tc)
166 float eps;
167 float x;
168 float y;
169 size_t i;
171 for (i = 0; i < __arraycount(values); i++) {
172 x = values[i].x;
173 y = values[i].y;
174 eps = 1e-6 * values[i].e;
176 if (fabsf(sinhf(x) - y) > eps)
177 atf_tc_fail_nonfatal("sinhf(%g) != %g\n", x, y);
181 ATF_TC(sinhf_nan);
182 ATF_TC_HEAD(sinhf_nan, tc)
184 atf_tc_set_md_var(tc, "descr", "Test sinhf(NaN) == NaN");
187 ATF_TC_BODY(sinhf_nan, tc)
189 const float x = 0.0L / 0.0L;
191 ATF_CHECK(isnan(x) != 0);
192 ATF_CHECK(isnan(sinhf(x)) != 0);
195 ATF_TC(sinhf_inf_neg);
196 ATF_TC_HEAD(sinhf_inf_neg, tc)
198 atf_tc_set_md_var(tc, "descr", "Test sinhf(-Inf) == -Inf");
201 ATF_TC_BODY(sinhf_inf_neg, tc)
203 const float x = -1.0L / 0.0L;
204 float y = sinhf(x);
206 ATF_CHECK(isinf(y) != 0);
207 ATF_CHECK(signbit(y) != 0);
210 ATF_TC(sinhf_inf_pos);
211 ATF_TC_HEAD(sinhf_inf_pos, tc)
213 atf_tc_set_md_var(tc, "descr", "Test sinhf(+Inf) == +Inf");
216 ATF_TC_BODY(sinhf_inf_pos, tc)
218 const float x = 1.0L / 0.0L;
219 float y = sinhf(x);
221 ATF_CHECK(isinf(y) != 0);
222 ATF_CHECK(signbit(y) == 0);
225 ATF_TC(sinhf_zero_neg);
226 ATF_TC_HEAD(sinhf_zero_neg, tc)
228 atf_tc_set_md_var(tc, "descr", "Test sinhf(-0.0) == -0.0");
231 ATF_TC_BODY(sinhf_zero_neg, tc)
233 const float x = -0.0L;
234 float y = sinhf(x);
236 if (fabsf(y) > 0.0 || signbit(y) == 0)
237 atf_tc_fail_nonfatal("sinhf(-0.0) != -0.0");
240 ATF_TC(sinhf_zero_pos);
241 ATF_TC_HEAD(sinhf_zero_pos, tc)
243 atf_tc_set_md_var(tc, "descr", "Test sinhf(+0.0) == +0.0");
246 ATF_TC_BODY(sinhf_zero_pos, tc)
248 const float x = 0.0L;
249 float y = sinhf(x);
251 if (fabsf(y) > 0.0 || signbit(y) != 0)
252 atf_tc_fail_nonfatal("sinhf(+0.0) != +0.0");
255 ATF_TP_ADD_TCS(tp)
258 ATF_TP_ADD_TC(tp, sinh_inrange);
259 ATF_TP_ADD_TC(tp, sinh_nan);
260 ATF_TP_ADD_TC(tp, sinh_inf_neg);
261 ATF_TP_ADD_TC(tp, sinh_inf_pos);
262 ATF_TP_ADD_TC(tp, sinh_zero_neg);
263 ATF_TP_ADD_TC(tp, sinh_zero_pos);
265 ATF_TP_ADD_TC(tp, sinhf_inrange);
266 ATF_TP_ADD_TC(tp, sinhf_nan);
267 ATF_TP_ADD_TC(tp, sinhf_inf_neg);
268 ATF_TP_ADD_TC(tp, sinhf_inf_pos);
269 ATF_TP_ADD_TC(tp, sinhf_zero_neg);
270 ATF_TP_ADD_TC(tp, sinhf_zero_pos);
272 return atf_no_error();