1/* Test file for mpfr_csc. 2 3Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. 4Contributed by the AriC and Caramel projects, INRIA. 5 6This file is part of the GNU MPFR Library. 7 8The GNU MPFR Library is free software; you can redistribute it and/or modify 9it under the terms of the GNU Lesser General Public License as published by 10the Free Software Foundation; either version 3 of the License, or (at your 11option) any later version. 12 13The GNU MPFR Library is distributed in the hope that it will be useful, but 14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16License for more details. 17 18You should have received a copy of the GNU Lesser General Public License 19along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see 20http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 2151 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ 22 23#include <stdio.h> 24#include <stdlib.h> 25 26#include "mpfr-test.h" 27 28#define TEST_FUNCTION mpfr_csc 29#define REDUCE_EMAX 262143 /* otherwise arg. reduction is too expensive */ 30#include "tgeneric.c" 31 32static void 33check_specials (void) 34{ 35 mpfr_t x, y; 36 37 mpfr_init2 (x, 123L); 38 mpfr_init2 (y, 123L); 39 40 mpfr_set_nan (x); 41 mpfr_csc (y, x, MPFR_RNDN); 42 if (! mpfr_nan_p (y)) 43 { 44 printf ("Error: csc(NaN) != NaN\n"); 45 exit (1); 46 } 47 48 mpfr_set_inf (x, 1); 49 mpfr_csc (y, x, MPFR_RNDN); 50 if (! mpfr_nan_p (y)) 51 { 52 printf ("Error: csc(Inf) != NaN\n"); 53 exit (1); 54 } 55 56 mpfr_set_inf (x, -1); 57 mpfr_csc (y, x, MPFR_RNDN); 58 if (! mpfr_nan_p (y)) 59 { 60 printf ("Error: csc(-Inf) != NaN\n"); 61 exit (1); 62 } 63 64 /* csc(+/-0) = +/-Inf */ 65 mpfr_set_ui (x, 0, MPFR_RNDN); 66 mpfr_csc (y, x, MPFR_RNDN); 67 if (! (mpfr_inf_p (y) && mpfr_sgn (y) > 0)) 68 { 69 printf ("Error: csc(+0) != +Inf\n"); 70 exit (1); 71 } 72 mpfr_neg (x, x, MPFR_RNDN); 73 mpfr_csc (y, x, MPFR_RNDN); 74 if (! (mpfr_inf_p (y) && mpfr_sgn (y) < 0)) 75 { 76 printf ("Error: csc(-0) != -Inf\n"); 77 exit (1); 78 } 79 80 mpfr_clear (x); 81 mpfr_clear (y); 82} 83 84int 85main (int argc, char *argv[]) 86{ 87 tests_start_mpfr (); 88 89 check_specials (); 90 91 test_generic (2, 100, 10); 92 93 tests_end_mpfr (); 94 return 0; 95} 96