diff options
author | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2009-02-04 13:10:54 +0000 |
---|---|---|
committer | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2009-02-04 13:10:54 +0000 |
commit | c1782f28abf00c806422f833901afaf1b84eaf9e (patch) | |
tree | f7fcb2a7876a46f3c96b1d94841060561193c7ed /tests/tprec.c | |
parent | fb75373c9c0cf5d29510459be85439283ab9d00b (diff) | |
download | mpc-c1782f28abf00c806422f833901afaf1b84eaf9e.tar.gz |
tests/test.c: enhance and move its tests into more specific files.
tests/tprec.c: move tests relative to mpc_set_prec/mpc_get_prec from test.c.
tests/tset.c: enhance and move tests relative to mpc_set from test.c.
tests/inp_str.dat: test data for tio_str.c
tests/tio_str.c: test file for mpc_inp_str/mpc_out_str.
tests/Makefile.am: remove test, add tprec, tset, tio_str and inp_str.dat.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@410 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/tprec.c')
-rw-r--r-- | tests/tprec.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/tprec.c b/tests/tprec.c new file mode 100644 index 0000000..4babc7c --- /dev/null +++ b/tests/tprec.c @@ -0,0 +1,71 @@ +/* tprec.c -- Test file for mpc_set_prec, mpc_get_prec and mpc_get_prec2. + +Copyright (C) 2009 Philippe Th\'eveny + +This file is part of the MPC Library. + +The MPC Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPC Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <stdlib.h> +#include "mpc-tests.h" +#include "mpc-impl.h" + +int +main (void) +{ + mpc_t z; + mp_prec_t prec, pr, pi; + + mpc_init2 (z, 1000); + + for (prec = 2; prec <= 1000; prec++) + { + /* check set_prec/get_prec */ + mpfr_set_prec (MPC_RE (z), prec); + mpfr_set_prec (MPC_IM (z), prec + 1); + if (mpc_get_prec (z) != 0) + { + printf ("Error in mpc_get_prec for prec (re) = %lu, " + "prec (im) = %lu\n", (unsigned long int) prec, + (unsigned long int) prec + 1ul); + + exit (1); + } + + mpc_get_prec2 (&pr, &pi, z); + if (pr != prec || pi != prec + 1) + { + printf ("Error in mpc_get_prec2 for prec (re) = %lu, " + "prec (im) = %lu\n", (unsigned long int) prec, + (unsigned long int) prec + 1ul); + + exit (1); + } + + mpc_set_prec (z, prec); + if (mpc_get_prec (z) != prec) + { + printf ("Error in mpc_get_prec for prec = %lu\n", + (unsigned long int) prec); + + exit (1); + } + } + + mpc_clear (z); + + return 0; +} |