1/* Test file for mpfr_const_catalan.
2
3Copyright 2005-2023 Free Software Foundation, Inc.
4Contributed by the AriC and Caramba projects, INRIA.
5
6This file is part of the GNU MPFR Library.
7
8The GNU MPFR Library is free software; you can redistribute it and/or modify
9it under the terms of the GNU Lesser General Public License as published by
10the Free Software Foundation; either version 3 of the License, or (at your
11option) any later version.
12
13The GNU MPFR Library is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16License for more details.
17
18You should have received a copy of the GNU Lesser General Public License
19along with the GNU MPFR Library; see the file COPYING.LESSER.  If not, see
20https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
2151 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22
23#include "mpfr-test.h"
24
25/* Wrapper for tgeneric */
26static int
27my_const_catalan (mpfr_ptr x, mpfr_srcptr y, mpfr_rnd_t r)
28{
29  return mpfr_const_catalan (x, r);
30}
31
32#define RAND_FUNCTION(x) mpfr_set_ui(x,0,MPFR_RNDN)
33#define TEST_FUNCTION my_const_catalan
34#include "tgeneric.c"
35
36static void
37exercise_Ziv (void)
38{
39  mpfr_t x, y;
40  int inex;
41
42  mpfr_init2 (x, 175);
43  mpfr_init2 (y, 175);
44  inex = mpfr_const_catalan (x, MPFR_RNDN);
45  mpfr_set_str_binary (y, "0.1110101001111100101110001001111101000000100110101110100001000101001000010101100000100010111000110111110100110010110100001100011000111110110001000011111000010011100000011100001");
46  MPFR_ASSERTN(mpfr_equal_p (x, y));
47  MPFR_ASSERTN(inex < 0);
48  mpfr_clear (x);
49  mpfr_clear (y);
50}
51
52int
53main (int argc, char *argv[])
54{
55  mpfr_t x;
56
57  tests_start_mpfr ();
58
59  exercise_Ziv ();
60  mpfr_init2 (x, 32);
61  (mpfr_const_catalan) (x, MPFR_RNDN);
62  mpfr_mul_2ui (x, x, 32, MPFR_RNDN);
63  if (mpfr_cmp_ui (x, 3934042271UL))
64    {
65      printf ("Error in const_catalan for prec=32\n");
66      exit (1);
67    }
68  mpfr_clear (x);
69
70  test_generic (MPFR_PREC_MIN, 200, 1);
71
72  tests_end_mpfr ();
73  return 0;
74}
75