blob: da07f3eef9d8500fe1d858b482a07b3cd532e754 [file] [log] [blame]
Austin Schuhdace2a62020-08-18 10:56:48 -07001/* Test mpf_get_prec and mpf_set_prec.
2
3Copyright 2000, 2001 Free Software Foundation, Inc.
4
5This file is part of the GNU MP Library test suite.
6
7The GNU MP Library test suite is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 3 of the License,
10or (at your option) any later version.
11
12The GNU MP Library test suite is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15Public License for more details.
16
17You should have received a copy of the GNU General Public License along with
18the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include "gmp-impl.h"
23#include "tests.h"
24
25void
26check_consistency (void)
27{
28 mpf_t x;
29 unsigned long i, a, b;
30
31 mpf_init (x);
32
33 for (i = 1; i < 2000; i++)
34 {
35 mpf_set_prec (x, i);
36 a = mpf_get_prec (x);
37 mpf_set_prec (x, a);
38 b = mpf_get_prec (x);
39 if (a != b)
40 {
41 printf ("mpf_get_prec / mpf_set_prec inconsistent\n");
42 printf (" set %lu gives %lu, but then set %lu gives %lu\n",
43 i, a,
44 a, b);
45 abort ();
46 }
47 }
48
49 mpf_clear (x);
50}
51
52int
53main (void)
54{
55 tests_start ();
56
57 check_consistency ();
58
59 tests_end ();
60 exit (0);
61}