diff options
author | zimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2012-06-26 15:09:15 +0000 |
---|---|---|
committer | zimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2012-06-26 15:09:15 +0000 |
commit | 27e679c97fe25163ca1a21e5443916636b8ea729 (patch) | |
tree | c4fcff99f54c25d657345723c2a5a85a2fc2bdde /tests/tatan.c | |
parent | fcc0f3529b397cddd67eda85c751085e79dc3922 (diff) | |
download | mpc-27e679c97fe25163ca1a21e5443916636b8ea729.tar.gz |
[tatan.c] added one test to improve the code coverage, which produces an
infinite loop in mpc_atan...
[atan.c] added a check to detect potential infinite loops
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1167 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/tatan.c')
-rw-r--r-- | tests/tatan.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/tatan.c b/tests/tatan.c index b46f694..89e476e 100644 --- a/tests/tatan.c +++ b/tests/tatan.c @@ -1,6 +1,6 @@ /* tatan -- test file for mpc_atan. -Copyright (C) 2009 INRIA +Copyright (C) 2009, 2012 INRIA This file is part of GNU MPC. @@ -20,6 +20,33 @@ along with this program. If not, see http://www.gnu.org/licenses/ . #include "mpc-tests.h" +static int +test_coverage (void) +{ + mpc_t z; + mpfr_exp_t emin = mpfr_get_emin (); + + mpfr_set_emin (-10); + mpc_init2 (z, 21); + mpfr_set_si (mpc_realref(z), -1, GMP_RNDZ); + mpfr_set_ui_2exp (mpc_imagref(z), 1, 20, GMP_RNDZ); + mpfr_add_ui (mpc_imagref(z), mpc_imagref(z), 1, GMP_RNDZ); + mpfr_div_2exp (mpc_imagref(z), mpc_imagref(z), 20, GMP_RNDZ); + mpc_atan (z, z, MPC_RNDNN); + if (mpfr_cmp_si_2exp (mpc_realref(z), -1066635, 20) != 0 || + mpfr_cmp_si_2exp (mpc_imagref(z), 1687619, 22)) + { + printf ("Error in test_coverage\n"); + printf ("expected (-1066635/2^20 1687619/2^22)\n"); + printf ("got "); + mpc_out_str (stdout, 10, 20, z, MPC_RNDNN); + printf ("\n"); + exit (1); + } + mpc_clear (z); + mpfr_set_emin (emin); +} + int main (void) { @@ -27,6 +54,8 @@ main (void) test_start (); + test_coverage (); + data_check (f, "atan.dat"); tgeneric (f, 2, 512, 5, 128); |