diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2016-05-24 09:18:36 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2016-05-24 09:18:36 +0000 |
commit | 8b14ec05edd32b9fae54c5975cab07a70bd0e7e4 (patch) | |
tree | 819b008e2cf1592fbad2b3f301760ede2cb161a6 /tests | |
parent | 18473b6775aa17c46b5f2b5aaaa4eca7de29d716 (diff) | |
download | mpfr-8b14ec05edd32b9fae54c5975cab07a70bd0e7e4.tar.gz |
added tests for mpfr_fpif_import with precision > MPFR_PREC_MAX
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@10338 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tfpif.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/tests/tfpif.c b/tests/tfpif.c index bfdfab8b9..907cf0a53 100644 --- a/tests/tfpif.c +++ b/tests/tfpif.c @@ -24,10 +24,12 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define FILE_NAME_RW "mpfrtest.txt" /* temporary name (written then read) */ #define FILE_NAME_R "mpfrtest.dat" /* fixed file name (read only) */ +#define FILE_NAME_R2 "mpfrtest2.dat" /* fixed file name (read only) with a + precision > MPFR_PREC_MAX */ /* TODO: add tests for precision 1 and for precisions > MPFR_PREC_MAX. */ -static int +static void doit (int argc, char *argv[], mpfr_prec_t p1, mpfr_prec_t p2) { char *filenameCompressed = FILE_NAME_RW; @@ -41,14 +43,6 @@ doit (int argc, char *argv[], mpfr_prec_t p1, mpfr_prec_t p2) int badDataSize[6] = { 1, 1, 2, 2, 2, 2 }; int i; - if (argc != 1) - { - printf ("Usage: %s\n", argv[0]); - exit (1); - } - - tests_start_mpfr (); - mpfr_init2 (x[0], p1); mpfr_init2 (x[8], p1); mpfr_inits2 (p2, x[1], x[2], x[3], x[4], x[5], x[6], x[7], (mpfr_ptr) 0); @@ -241,17 +235,43 @@ doit (int argc, char *argv[], mpfr_prec_t p1, mpfr_prec_t p2) remove (filenameCompressed); mpfr_clear (y); +} - tests_end_mpfr (); - return 0; +/* exercise error when precision > MPFR_PREC_MAX */ +static void +extra (void) +{ + mpfr_t x; + FILE *fp; + int ret; + + mpfr_init2 (x, 17); + mpfr_set_ui (x, 42, MPFR_RNDN); + fp = fopen (FILE_NAME_R2, "r"); + ret = mpfr_fpif_import (x, fp); + MPFR_ASSERTN(ret != 0); + MPFR_ASSERTN(mpfr_get_prec (x) == 17); + MPFR_ASSERTN(mpfr_cmp_ui (x, 42) == 0); + fclose (fp); + mpfr_clear (x); } int main (int argc, char *argv[]) { - int ret; + if (argc != 1) + { + printf ("Usage: %s\n", argv[0]); + exit (1); + } - ret = doit (argc, argv, 130, 2048); - ret = ret || doit (argc, argv, 1, 53); - return ret; + tests_start_mpfr (); + + extra (); + doit (argc, argv, 130, 2048); + doit (argc, argv, 1, 53); + + tests_end_mpfr (); + + return 0; } |