summaryrefslogtreecommitdiff
path: root/tests/read_data.c
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2010-04-01 16:12:49 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2010-04-01 16:12:49 +0000
commit6308d97dd767efaa43e8b48dc8642005c817d44e (patch)
treee665d2d9be5d5b964b9c5108168e4611d9f30d12 /tests/read_data.c
parentc4c5d3fd54b6ad717f44cd50134e6ed257d629c0 (diff)
downloadmpc-6308d97dd767efaa43e8b48dc8642005c817d44e.tar.gz
pow_ui.c:
cases of over-/underflow delegated to mpc_pow pow_ui.dat, read_data.c, tpow_ui.c: added test file tests/Makefile.am: temporarily moved test of pow_ui to the front git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@752 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/read_data.c')
-rw-r--r--tests/read_data.c78
1 files changed, 74 insertions, 4 deletions
diff --git a/tests/read_data.c b/tests/read_data.c
index cca7dfc..4129027 100644
--- a/tests/read_data.c
+++ b/tests/read_data.c
@@ -1,6 +1,6 @@
/* Read data file and check function.
-Copyright (C) 2008, 2009 Andreas Enge, Philippe Th\'eveny
+Copyright (C) 2008, 2009, 2010 Andreas Enge, Philippe Th\'eveny
This file is part of the MPC Library.
@@ -282,7 +282,7 @@ read_int (FILE *fp, int *nread, const char *name)
if (nextchar == EOF)
{
- printf ("Error: Unexpected EOF when reading mpfr precision "
+ printf ("Error: Unexpected EOF when reading int "
"in file '%s' line %lu\n",
pathname, line_number);
exit (1);
@@ -299,6 +299,30 @@ read_int (FILE *fp, int *nread, const char *name)
skip_whitespace_comments (fp);
}
+void
+read_uint (FILE *fp, unsigned long int *ui)
+{
+ int n = 0;
+
+ if (nextchar == EOF)
+ {
+ printf ("Error: Unexpected EOF when reading uint "
+ "in file '%s' line %lu\n",
+ pathname, line_number);
+ exit (1);
+ }
+ ungetc (nextchar, fp);
+ n = fscanf (fp, "%lu", ui);
+ if (ferror (fp) || n == 0 || n == EOF)
+ {
+ printf ("Error: Cannot read uint in file '%s' line %lu\n",
+ pathname, line_number);
+ exit (1);
+ }
+ nextchar = getc (fp);
+ skip_whitespace_comments (fp);
+}
+
mpfr_prec_t
read_mpfr_prec (FILE *fp)
{
@@ -458,6 +482,21 @@ read_ccf (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
check_compatible (*inex_im, MPC_IM(expected), MPC_RND_IM(*rnd), "imag");
}
+static void
+read_ccu (FILE *fp, int *inex_re, int *inex_im, mpc_ptr expected,
+ known_signs_t *signs, mpc_ptr op1, unsigned long int *op2, mpc_rnd_t *rnd)
+{
+ test_line_number = line_number;
+ read_ternary (fp, inex_re);
+ read_ternary (fp, inex_im);
+ read_mpc (fp, expected, signs);
+ read_mpc (fp, op1, NULL);
+ read_uint (fp, op2);
+ read_mpc_rounding_mode (fp, rnd);
+ check_compatible (*inex_re, MPC_RE(expected), MPC_RND_RE(*rnd), "real");
+ check_compatible (*inex_im, MPC_IM(expected), MPC_RND_IM(*rnd), "imag");
+}
+
/* data_check (function, data_file_name) checks function results against
precomputed data in a file.*/
void
@@ -473,6 +512,9 @@ data_check (mpc_function function, const char *file_name)
int inex_im;
mpc_t z1, z2, z3, z4;
mpc_rnd_t rnd = MPC_RNDNN;
+
+ unsigned long int ui;
+
known_signs_t signs;
int inex = 0;
@@ -486,7 +528,7 @@ data_check (mpc_function function, const char *file_name)
mpfr_init (x1);
mpfr_init (x2);
break;
- case CC:
+ case CC: case CCU:
mpc_init2 (z2, 2);
mpc_init2 (z3, 2);
break;
@@ -689,6 +731,34 @@ data_check (mpc_function function, const char *file_name)
}
break;
+ case CCU: /* example mpc_pow_ui */
+ read_ccu (fp, &inex_re, &inex_im, z1, &signs, z2, &ui, &rnd);
+ mpfr_set_prec (MPC_RE(z3), MPC_PREC_RE (z1));
+ mpfr_set_prec (MPC_IM(z3), MPC_PREC_IM (z1));
+ inex = function.pointer.CCU (z3, z2, ui, rnd);
+ if (!MPC_INEX_CMP (inex_re, inex_im, inex)
+ || !same_mpc_value (z3, z1, signs))
+ {
+ /* display sensible variable names */
+ mpc_t op1, got, expected;
+ op1[0] = z2[0];
+ expected[0]= z1[0];
+ got[0] = z3[0];
+ printf ("%s(op) failed (line %lu)\nwith rounding mode %s\n",
+ function.name, test_line_number, rnd_mode[rnd]);
+ if (!MPC_INEX_CMP (inex_re, inex_im, inex))
+ printf("ternary value: got %s, expected (%s, %s)\n",
+ MPC_INEX_STR (inex),
+ MPFR_INEX_STR (inex_re), MPFR_INEX_STR (inex_im));
+ OUT (op1);
+ printf ("op2 %lu\n ", ui);
+ OUT (got);
+ OUT (expected);
+
+ exit (1);
+ }
+ break;
+
default:
;
}
@@ -702,7 +772,7 @@ data_check (mpc_function function, const char *file_name)
mpfr_clear (x1);
mpfr_clear (x2);
break;
- case CC:
+ case CC: case CCU:
mpc_clear (z2);
mpc_clear (z3);
break;