summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-10-29 15:57:13 +0000
committerthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-10-29 15:57:13 +0000
commitcd289b9c420ea0758348b81e20e94974c731f904 (patch)
treee9bb49c77d867fdc392ff9532dc8462ee07c6539
parentaa0bc442be9598b904f09435af6f141fcac04667 (diff)
downloadmpc-cd289b9c420ea0758348b81e20e94974c731f904.tar.gz
Add templated tests for pow.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/branches/benchs_tests@1293 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/pow.dsc30
-rw-r--r--tests/tpow_tmpl.c81
3 files changed, 118 insertions, 7 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a32c01b..ebddba7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,8 +28,8 @@ AM_LDFLAGS = -no-install
LOADLIBES=$(DEFS) -I$(top_srcdir)/src -I$(top_builddir) $(CPPFLAGS) \
$(CFLAGS) -L$(top_builddir)/tests/.libs -lmpc-tests -lmpc -lm $(LIBS)
-TEMPLATED = tadd_tmpl tadd_fr_tmpl tmul_tmpl tpow_si_tmpl tpow_ui_tmpl
-
+TEMPLATED = tadd_tmpl tadd_fr_tmpl tmul_tmpl tpow_tmpl tpow_si_tmpl \
+ tpow_ui_tmpl
check_PROGRAMS = tabs tacos tacosh tadd tadd_fr tadd_si tadd_ui targ \
tasin tasinh tatan tatanh tconj tcos tcosh tdiv tdiv_2exp tdiv_fr \
tdiv_ui texp tfma tfr_div tfr_sub timag tio_str tlog tlog10 tmul \
@@ -45,15 +45,15 @@ libmpc_tests_la_SOURCES=mpc-tests.h random.c tgeneric.c read_data.c \
print_parameter.c read_description.c read_line.c tpl_mpc.c \
tpl_mpfr.c tpl_native.c
-TEMPLATES = data_check.tpl add.dsc add_fr.dsc add_si.dsc add_ui.dsc mul.dsc \
- pow_si.dsc pow_ui.dsc
-
-EXTRA_DIST = abs.dat acos.dat acosh.dat asin.dat asinh.dat atan.dat \
+TEMPLATES = data_check.tpl add.dsc add_fr.dsc add_si.dsc add_ui.dsc mul.dsc \
+ pow.dsc pow_si.dsc pow_ui.dsc
+DATA_SETS = abs.dat acos.dat acosh.dat asin.dat asinh.dat atan.dat \
atanh.dat add.dat add_fr.dat arg.dat conj.dat cos.dat cosh.dat \
div.dat div_fr.dat exp.dat fma.dat fr_div.dat fr_sub.dat inp_str.dat \
log.dat log10.dat mul.dat mul_fr.dat neg.dat norm.dat pow.dat \
pow_fr.dat pow_si.dat pow_ui.dat proj.dat sin.dat sinh.dat sqr.dat \
- sqrt.dat strtoc.dat sub.dat sub_fr.dat tan.dat tanh.dat $(TEMPLATES)
+ sqrt.dat strtoc.dat sub.dat sub_fr.dat tan.dat tanh.dat
+EXTRA_DIST = $(DATA_SETS) $(TEMPLATES)
TESTS_ENVIRONMENT = $(VALGRIND)
TESTS = $(check_PROGRAMS)
diff --git a/tests/pow.dsc b/tests/pow.dsc
new file mode 100644
index 0000000..1a4afac
--- /dev/null
+++ b/tests/pow.dsc
@@ -0,0 +1,30 @@
+# Description file for mpc_pow
+#
+# Copyright (C) 2012 INRIA
+#
+# This file is part of GNU MPC.
+#
+# GNU MPC 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 3 of the License, or (at your
+#o ption) any later version.
+#
+# GNU MPC 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 this program. If not, see http://www.gnu.org/licenses/ .
+#
+# Description file of the function
+NAME:
+ mpc_pow
+RETURN:
+ mpc_inex
+OUTPUT:
+ mpc_ptr
+INPUT:
+ mpc_srcptr
+ mpc_srcptr
+ mpc_rnd_t
diff --git a/tests/tpow_tmpl.c b/tests/tpow_tmpl.c
new file mode 100644
index 0000000..499e3da
--- /dev/null
+++ b/tests/tpow_tmpl.c
@@ -0,0 +1,81 @@
+/* tpow_tmpl.c -- test file for mpc_pow.
+
+Copyright (C) 2009, 2011 INRIA
+
+This file is part of GNU MPC.
+
+GNU MPC 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 3 of the License, or (at your
+option) any later version.
+
+GNU MPC 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 this program. If not, see http://www.gnu.org/licenses/ .
+*/
+
+#include "templates.h"
+#include "mpc-tests.h"
+
+static void
+reuse_bug (void)
+{
+ /* bug found by the automatic builds on
+ http://hydra.nixos.org/build/1469029/log/raw */
+ mpc_t x, y, z;
+ mp_prec_t prec = 2;
+
+ for (prec = 2; prec <= 20; prec ++)
+ {
+ mpc_init2 (x, prec);
+ mpc_init2 (y, prec);
+ mpc_init2 (z, prec);
+
+ mpfr_set_ui (mpc_realref (x), 0ul, GMP_RNDN);
+ mpfr_set_ui_2exp (mpc_imagref (x), 3ul, -2, GMP_RNDN);
+ mpc_set_ui (y, 8ul, MPC_RNDNN);
+
+ mpc_pow (z, x, y, MPC_RNDNN);
+ mpc_pow (y, x, y, MPC_RNDNN);
+ if (mpfr_signbit (mpc_imagref (y)) != mpfr_signbit (mpc_imagref (z)))
+ {
+ printf ("Error: regression, reuse_bug reproduced\n");
+ exit (1);
+ }
+
+ mpc_clear (x);
+ mpc_clear (y);
+ mpc_clear (z);
+ }
+}
+
+#define MPC_FUNCTION_CALL \
+ P[0].mpc_inex = mpc_pow (P[1].mpc, P[2].mpc, P[3].mpc, P[4].mpc_rnd)
+#define MPC_FUNCTION_CALL_REUSE_OP1 \
+ P[0].mpc_inex = mpc_pow (P[1].mpc, P[1].mpc, P[3].mpc, P[4].mpc_rnd)
+#define MPC_FUNCTION_CALL_REUSE_OP2 \
+ P[0].mpc_inex = mpc_pow (P[1].mpc, P[2].mpc, P[1].mpc, P[4].mpc_rnd)
+
+#include "data_check.tpl"
+
+int
+main (void)
+{
+ DECL_FUNC (C_CC, f, mpc_pow);
+
+ test_start ();
+
+ reuse_bug ();
+
+ data_check_template ("pow.dsc", "pow.dat");
+
+ tgeneric (f, 2, 1024, 7, 10);
+
+ test_end ();
+
+ return 0;
+}