tools/llvm: Do not build with symbols
[minix3.git] / tests / lib / libm / t_sinh.c
blobcebf90de1c89ddc3a36d6d93aea3620eff4c2a9d
1 /* $NetBSD: t_sinh.c,v 1.5 2013/04/09 12:11:04 isaki 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.5 2013/04/09 12:11:04 isaki 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 #ifndef __vax__
67 double eps;
68 double x;
69 double y;
70 size_t i;
72 for (i = 0; i < __arraycount(values); i++) {
73 x = values[i].x;
74 y = values[i].y;
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);
80 #endif
83 ATF_TC(sinh_nan);
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)
91 #ifndef __vax__
92 const double x = 0.0L / 0.0L;
94 ATF_CHECK(isnan(x) != 0);
95 ATF_CHECK(isnan(sinh(x)) != 0);
96 #endif
99 ATF_TC(sinh_inf_neg);
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)
107 #ifndef __vax__
108 const double x = -1.0L / 0.0L;
109 double y = sinh(x);
111 ATF_CHECK(isinf(y) != 0);
112 ATF_CHECK(signbit(y) != 0);
113 #endif
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)
124 #ifndef __vax__
125 const double x = 1.0L / 0.0L;
126 double y = sinh(x);
128 ATF_CHECK(isinf(y) != 0);
129 ATF_CHECK(signbit(y) == 0);
130 #endif
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)
141 #ifndef __vax__
142 const double x = -0.0L;
143 double y = sinh(x);
145 if (fabs(y) > 0.0 || signbit(y) == 0)
146 atf_tc_fail_nonfatal("sinh(-0.0) != -0.0");
147 #endif
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)
158 #ifndef __vax__
159 const double x = 0.0L;
160 double y = sinh(x);
162 if (fabs(y) > 0.0 || signbit(y) != 0)
163 atf_tc_fail_nonfatal("sinh(+0.0) != +0.0");
164 #endif
168 * sinhf(3)
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)
178 #ifndef __vax__
179 float eps;
180 float x;
181 float y;
182 size_t i;
184 for (i = 0; i < __arraycount(values); i++) {
185 x = values[i].x;
186 y = values[i].y;
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);
192 #endif
195 ATF_TC(sinhf_nan);
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)
203 #ifndef __vax__
204 const float x = 0.0L / 0.0L;
206 ATF_CHECK(isnan(x) != 0);
207 ATF_CHECK(isnan(sinhf(x)) != 0);
208 #endif
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)
219 #ifndef __vax__
220 const float x = -1.0L / 0.0L;
221 float y = sinhf(x);
223 ATF_CHECK(isinf(y) != 0);
224 ATF_CHECK(signbit(y) != 0);
225 #endif
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)
236 #ifndef __vax__
237 const float x = 1.0L / 0.0L;
238 float y = sinhf(x);
240 ATF_CHECK(isinf(y) != 0);
241 ATF_CHECK(signbit(y) == 0);
242 #endif
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)
253 #ifndef __vax__
254 const float x = -0.0L;
255 float y = sinhf(x);
257 if (fabsf(y) > 0.0 || signbit(y) == 0)
258 atf_tc_fail_nonfatal("sinhf(-0.0) != -0.0");
259 #endif
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)
270 #ifndef __vax__
271 const float x = 0.0L;
272 float y = sinhf(x);
274 if (fabsf(y) > 0.0 || signbit(y) != 0)
275 atf_tc_fail_nonfatal("sinhf(+0.0) != +0.0");
276 #endif
279 ATF_TP_ADD_TCS(tp)
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();