1 /* tpow_z -- test file for mpc_pow_z.
2
3 Copyright (C) 2009, 2011, 2012, 2013 INRIA
4
5 This file is part of GNU MPC.
6
7 GNU MPC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU Lesser General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see http://www.gnu.org/licenses/ .
19 */
20
21 #include <limits.h> /* for CHAR_BIT */
22 #include "mpc-tests.h"
23
24 static void
test_large(void)25 test_large (void)
26 {
27 mpc_t z;
28 mpz_t t;
29
30 mpc_init2 (z, 5);
31 mpz_init_set_ui (t, 1ul);
32
33 mpz_set_ui (t, 1ul);
34 mpz_mul_2exp (t, t, sizeof (long) * CHAR_BIT);
35 mpc_set_ui_ui (z, 0ul, 1ul, MPC_RNDNN);
36 mpc_pow_z (z, z, t, MPC_RNDNN);
37 if (mpc_cmp_si_si (z, 1l, 0l) != 0) {
38 printf ("Error for mpc_pow_z (4*large)\n");
39 exit (1);
40 }
41
42 mpc_clear (z);
43 mpz_clear (t);
44 }
45
46 #define MPC_FUNCTION_CALL \
47 P[0].mpc_inex = mpc_pow_z (P[1].mpc, P[2].mpc, P[3].mpz, P[4].mpc_rnd)
48 #define MPC_FUNCTION_CALL_REUSE_OP1 \
49 P[0].mpc_inex = mpc_pow_z (P[1].mpc, P[1].mpc, P[3].mpz, P[4].mpc_rnd)
50
51 #include "data_check.tpl"
52
53 int
main(void)54 main (void)
55 {
56 test_start ();
57
58 data_check_template ("pow_z.dsc", "pow_z.dat");
59
60 test_large ();
61
62 test_end ();
63
64 return 0;
65 }
66