summaryrefslogtreecommitdiff
path: root/tests/tpow_z.c
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2011-02-23 17:29:40 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2011-02-23 17:29:40 +0000
commit9512dba7e0bdb7ae03a66f5e3b1f97dd188b49d8 (patch)
treeb86718f48124495da80403c8cb94ef6371cb781b /tests/tpow_z.c
parentaf5c73c9a2119138437666180f760551c9abf577 (diff)
downloadmpc-9512dba7e0bdb7ae03a66f5e3b1f97dd188b49d8.tar.gz
tpow_z.c: full test coverage
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@956 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tests/tpow_z.c')
-rw-r--r--tests/tpow_z.c58
1 files changed, 37 insertions, 21 deletions
diff --git a/tests/tpow_z.c b/tests/tpow_z.c
index 47f0cbb..faf29a3 100644
--- a/tests/tpow_z.c
+++ b/tests/tpow_z.c
@@ -1,6 +1,6 @@
/* test file for mpc_pow_z.
-Copyright (C) INRIA, 2009
+Copyright (C) INRIA, 2009, 2011
This file is part of the MPC Library.
@@ -19,29 +19,45 @@ 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 <limits.h> /* for CHAR_BIT */
#include "mpc-tests.h"
int
main (void)
{
- mpc_t z;
- mpz_t t;
-
- test_start ();
-
- mpc_init2 (z, 5);
- mpz_init_set_ui (t, 1);
- mpc_set_ui_ui (z, 17, 42, MPC_RNDNN);
- mpc_pow_z (z, z, t, MPC_RNDNN);
- if (mpc_cmp_si_si (z, 17, 42) != 0)
- {
- printf ("Error for mpc_pow_z (1)\n");
- exit (1);
- }
- mpc_clear (z);
- mpz_clear (t);
-
- test_end ();
-
- return 0;
+ mpc_t z;
+ mpz_t t;
+
+ test_start ();
+
+ mpc_init2 (z, 5);
+ mpz_init_set_ui (t, 1ul);
+ mpc_set_ui_ui (z, 17ul, 42ul, MPC_RNDNN);
+ mpc_pow_z (z, z, t, MPC_RNDNN);
+ if (mpc_cmp_si_si (z, 17l, 42l) != 0) {
+ printf ("Error for mpc_pow_z (1)\n");
+ exit (1);
+ }
+ mpz_set_si (t, -1l);
+ mpc_set_ui_ui (z, 1ul, 1ul, MPC_RNDNN);
+ mpc_pow_z (z, z, t, MPC_RNDNN);
+ mpc_mul_ui (z, z, 2ul, MPC_RNDNN);
+ if (mpc_cmp_si_si (z, 1l, -1l) != 0) {
+ printf ("Error for mpc_pow_z (-1)\n");
+ exit (1);
+ }
+ mpz_set_ui (t, 1ul);
+ mpz_mul_2exp (t, t, sizeof (long) * CHAR_BIT);
+ mpc_set_ui_ui (z, 0ul, 1ul, MPC_RNDNN);
+ mpc_pow_z (z, z, t, MPC_RNDNN);
+ if (mpc_cmp_si_si (z, 1l, 0l) != 0) {
+ printf ("Error for mpc_pow_z (4*large)\n");
+ exit (1);
+ }
+ mpc_clear (z);
+ mpz_clear (t);
+
+ test_end ();
+
+ return 0;
}