1 /* $NetBSD: t_atan.c,v 1.15 2014/03/17 11:08:11 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.
41 /* vax has no +/- INF */
42 { T_LIBM_MINUS_INF
, -M_PI
/ 2 },
43 { T_LIBM_PLUS_INF
, M_PI
/ 2 },
45 { -100, -1.560796660108231, },
46 { -10, -1.471127674303735, },
48 { -0.1, -0.09966865249116204, },
49 { 0.1, 0.09966865249116204, },
51 { 10, 1.471127674303735, },
52 { 100, 1.560796660108231, },
58 ATF_LIBM_TEST(atan_nan
, "Test atan/atanf(NaN) == NaN")
61 T_LIBM_CHECK_NAN(0, atan
, T_LIBM_NAN
);
62 T_LIBM_CHECK_NAN(0, atanf
, T_LIBM_NAN
);
64 atf_tc_skip("no NaN on this machine");
68 ATF_LIBM_TEST(atan_inrange
, "Test atan/atanf(x) for some values")
72 for (i
= 0; i
< __arraycount(values
); i
++) {
73 T_LIBM_CHECK(i
, atan
, values
[i
].x
, values
[i
].y
, 1.0e-15);
74 T_LIBM_CHECK(i
, atanf
, values
[i
].x
, values
[i
].y
, 1.0e-7);
78 ATF_LIBM_TEST(atan_zero_neg
, "Test atan/atanf(-0.0) == -0.0")
81 T_LIBM_CHECK_MINUS_ZERO(0, atan
, -0.0);
82 T_LIBM_CHECK_MINUS_ZERO(0, atanf
, -0.0);
85 ATF_LIBM_TEST(atan_zero_pos
, "Test atan/atanf(+0.0) == +0.0")
88 T_LIBM_CHECK_PLUS_ZERO(0, atan
, +0.0);
89 T_LIBM_CHECK_PLUS_ZERO(0, atanf
, +0.0);
95 ATF_TP_ADD_TC(tp
, atan_nan
);
96 ATF_TP_ADD_TC(tp
, atan_inrange
);
97 ATF_TP_ADD_TC(tp
, atan_zero_neg
);
98 ATF_TP_ADD_TC(tp
, atan_zero_pos
);
100 return atf_no_error();