1/* tprec -- Test file for mpc_set_prec, mpc_get_prec and mpc_get_prec2. 2 3Copyright (C) 2009, 2011 INRIA 4 5This file is part of GNU MPC. 6 7GNU MPC is free software; you can redistribute it and/or modify it under 8the terms of the GNU Lesser General Public License as published by the 9Free Software Foundation; either version 3 of the License, or (at your 10option) any later version. 11 12GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY 13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 15more details. 16 17You should have received a copy of the GNU Lesser General Public License 18along with this program. If not, see http://www.gnu.org/licenses/ . 19*/ 20 21#include <stdlib.h> 22#include "mpc-tests.h" 23 24int 25main (void) 26{ 27 mpc_t z; 28 mpfr_prec_t prec, pr, pi; 29 30 mpc_init2 (z, 1000); 31 32 for (prec = 2; prec <= 1000; prec++) 33 { 34 /* check set_prec/get_prec */ 35 mpfr_set_prec (mpc_realref (z), prec); 36 mpfr_set_prec (mpc_imagref (z), prec + 1); 37 if (mpc_get_prec (z) != 0) 38 { 39 printf ("Error in mpc_get_prec for prec (re) = %lu, " 40 "prec (im) = %lu\n", (unsigned long int) prec, 41 (unsigned long int) prec + 1ul); 42 43 exit (1); 44 } 45 46 mpc_get_prec2 (&pr, &pi, z); 47 if (pr != prec || pi != prec + 1) 48 { 49 printf ("Error in mpc_get_prec2 for prec (re) = %lu, " 50 "prec (im) = %lu\n", (unsigned long int) prec, 51 (unsigned long int) prec + 1ul); 52 53 exit (1); 54 } 55 56 mpc_set_prec (z, prec); 57 if (mpc_get_prec (z) != prec) 58 { 59 printf ("Error in mpc_get_prec for prec = %lu\n", 60 (unsigned long int) prec); 61 62 exit (1); 63 } 64 } 65 66 mpc_clear (z); 67 68 return 0; 69} 70