1 /* tcos -- test file for mpc_cos.
2 
3 Copyright (C) 2008, 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 "mpc-tests.h"
22 
23 static void
bug20090105(void)24 bug20090105 (void)
25 {
26   /* this bug appeared on 32-bits machines */
27   mpc_t op, expected, got;
28   mpc_init2 (op, 324);
29   mpc_init2 (expected, 324);
30   mpc_init2 (got, 324);
31 
32   mpfr_set_str (mpc_realref(op), "-3.f1813b1487372434fea4414a520f65a343a16d0ec1ffb"
33                 "b2b880154db8d63377ce788fc4215c450300@1", 16, MPFR_RNDN);
34   mpfr_set_str (mpc_imagref(op), "-2.b7a0c80bcacf1ccbbac614bf53a58b672b1b503161bee"
35                 "59a82e46a23570b652f7ba5f01ef766d1c50", 16,MPFR_RNDN);
36   mpfr_set_str (mpc_realref(expected), "7.57c5b08a2b11b660d906a354289b0724b9c4b237"
37                 "95abe33424e8d9858e534bd5d776ddd18e34b0240", 16, MPFR_RNDN);
38   mpfr_set_str (mpc_imagref(expected), "-1.f41a389646d068e0263561cb3c5d1df763945ad"
39                 "ed9339f2a98387a3c4f97dbfd8a08b7d0af2f11b46", 16,MPFR_RNDN);
40 
41   mpc_cos (got, op, MPC_RNDNN);
42   if (mpc_cmp (got, expected) != 0)
43     TEST_FAILED ("mpc_cos", op, got, expected, MPC_RNDNN);
44 
45   mpc_clear (got);
46   mpc_clear(expected);
47   mpc_clear (op);
48 }
49 
50 #define MPC_FUNCTION_CALL                                       \
51   P[0].mpc_inex = mpc_cos (P[1].mpc, P[2].mpc, P[3].mpc_rnd)
52 #define MPC_FUNCTION_CALL_REUSE_OP1                             \
53   P[0].mpc_inex = mpc_cos (P[1].mpc, P[1].mpc, P[3].mpc_rnd)
54 
55 #include "data_check.tpl"
56 #include "tgeneric.tpl"
57 
58 int
main(void)59 main (void)
60 {
61   test_start ();
62 
63   data_check_template ("cos.dsc", "cos.dat");
64 
65   tgeneric_template ("cos.dsc", 2, 512, 7, 7);
66 
67   bug20090105 (); /* TODO: move data in cos.dat */
68 
69   test_end ();
70 
71   return 0;
72 }
73