Austin Schuh | dace2a6 | 2020-08-18 10:56:48 -0700 | [diff] [blame^] | 1 | /* Test mpf_get_prec and mpf_set_prec. |
| 2 | |
| 3 | Copyright 2000, 2001 Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of the GNU MP Library test suite. |
| 6 | |
| 7 | The GNU MP Library test suite is free software; you can redistribute it |
| 8 | and/or modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation; either version 3 of the License, |
| 10 | or (at your option) any later version. |
| 11 | |
| 12 | The GNU MP Library test suite is distributed in the hope that it will be |
| 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
| 15 | Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License along with |
| 18 | the 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 | |
| 25 | void |
| 26 | check_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 | |
| 52 | int |
| 53 | main (void) |
| 54 | { |
| 55 | tests_start (); |
| 56 | |
| 57 | check_consistency (); |
| 58 | |
| 59 | tests_end (); |
| 60 | exit (0); |
| 61 | } |