1272343Sngie/* $NetBSD: t_atan.c,v 1.15 2014/03/17 11:08:11 martin Exp $ */ 2272343Sngie 3272343Sngie/*- 4272343Sngie * Copyright (c) 2011 The NetBSD Foundation, Inc. 5272343Sngie * All rights reserved. 6272343Sngie * 7272343Sngie * This code is derived from software contributed to The NetBSD Foundation 8272343Sngie * by Jukka Ruohonen. 9272343Sngie * 10272343Sngie * Redistribution and use in source and binary forms, with or without 11272343Sngie * modification, are permitted provided that the following conditions 12272343Sngie * are met: 13272343Sngie * 1. Redistributions of source code must retain the above copyright 14272343Sngie * notice, this list of conditions and the following disclaimer. 15272343Sngie * 2. Redistributions in binary form must reproduce the above copyright 16272343Sngie * notice, this list of conditions and the following disclaimer in the 17272343Sngie * documentation and/or other materials provided with the distribution. 18272343Sngie * 19272343Sngie * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20272343Sngie * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21272343Sngie * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22272343Sngie * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23272343Sngie * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24272343Sngie * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25272343Sngie * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26272343Sngie * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27272343Sngie * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28272343Sngie * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29272343Sngie * POSSIBILITY OF SUCH DAMAGE. 30272343Sngie */ 31272343Sngie 32272343Sngie#include <atf-c.h> 33272343Sngie#include <math.h> 34272343Sngie#include "t_libm.h" 35272343Sngie 36272343Sngiestatic const struct { 37272343Sngie double x; 38272343Sngie double y; 39272343Sngie} values[] = { 40272343Sngie#ifndef __vax__ 41272343Sngie /* vax has no +/- INF */ 42272343Sngie { T_LIBM_MINUS_INF, -M_PI / 2 }, 43272343Sngie { T_LIBM_PLUS_INF, M_PI / 2 }, 44272343Sngie#endif 45272343Sngie { -100, -1.560796660108231, }, 46272343Sngie { -10, -1.471127674303735, }, 47272343Sngie { -1, -M_PI / 4, }, 48272343Sngie { -0.1, -0.09966865249116204, }, 49272343Sngie { 0.1, 0.09966865249116204, }, 50272343Sngie { 1, M_PI / 4, }, 51272343Sngie { 10, 1.471127674303735, }, 52272343Sngie { 100, 1.560796660108231, }, 53272343Sngie}; 54272343Sngie 55272343Sngie/* 56272343Sngie * atan(3) 57272343Sngie */ 58272343SngieATF_LIBM_TEST(atan_nan, "Test atan/atanf(NaN) == NaN") 59272343Sngie{ 60272343Sngie#ifdef T_LIBM_NAN 61272343Sngie T_LIBM_CHECK_NAN(0, atan, T_LIBM_NAN); 62272343Sngie T_LIBM_CHECK_NAN(0, atanf, T_LIBM_NAN); 63272343Sngie#else 64272343Sngie atf_tc_skip("no NaN on this machine"); 65272343Sngie#endif 66272343Sngie} 67272343Sngie 68272343SngieATF_LIBM_TEST(atan_inrange, "Test atan/atanf(x) for some values") 69272343Sngie{ 70272343Sngie unsigned int i; 71272343Sngie 72272343Sngie for (i = 0; i < __arraycount(values); i++) { 73272343Sngie T_LIBM_CHECK(i, atan, values[i].x, values[i].y, 1.0e-15); 74272343Sngie T_LIBM_CHECK(i, atanf, values[i].x, values[i].y, 1.0e-7); 75272343Sngie } 76272343Sngie} 77272343Sngie 78272343SngieATF_LIBM_TEST(atan_zero_neg, "Test atan/atanf(-0.0) == -0.0") 79272343Sngie{ 80272343Sngie 81272343Sngie T_LIBM_CHECK_MINUS_ZERO(0, atan, -0.0); 82272343Sngie T_LIBM_CHECK_MINUS_ZERO(0, atanf, -0.0); 83272343Sngie} 84272343Sngie 85272343SngieATF_LIBM_TEST(atan_zero_pos, "Test atan/atanf(+0.0) == +0.0") 86272343Sngie{ 87272343Sngie 88272343Sngie T_LIBM_CHECK_PLUS_ZERO(0, atan, +0.0); 89272343Sngie T_LIBM_CHECK_PLUS_ZERO(0, atanf, +0.0); 90272343Sngie} 91272343Sngie 92272343SngieATF_TP_ADD_TCS(tp) 93272343Sngie{ 94272343Sngie 95272343Sngie ATF_TP_ADD_TC(tp, atan_nan); 96272343Sngie ATF_TP_ADD_TC(tp, atan_inrange); 97272343Sngie ATF_TP_ADD_TC(tp, atan_zero_neg); 98272343Sngie ATF_TP_ADD_TC(tp, atan_zero_pos); 99272343Sngie 100272343Sngie return atf_no_error(); 101272343Sngie} 102