Revision 22254,
1.6 KB
checked in by ghudson, 19 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r22253,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | /* Test mpz_gcd_ui. |
---|
2 | |
---|
3 | Copyright 2003 Free Software Foundation, Inc. |
---|
4 | |
---|
5 | This file is part of the GNU MP Library. |
---|
6 | |
---|
7 | The GNU MP Library is free software; you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU Lesser General Public License as published by |
---|
9 | the Free Software Foundation; either version 2.1 of the License, or (at your |
---|
10 | option) any later version. |
---|
11 | |
---|
12 | The GNU MP Library is distributed in the hope that it will be useful, but |
---|
13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
---|
14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
---|
15 | License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU Lesser General Public License |
---|
18 | along with the GNU MP Library; see the file COPYING.LIB. If not, write to |
---|
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
---|
20 | MA 02111-1307, USA. */ |
---|
21 | |
---|
22 | #include <stdio.h> |
---|
23 | #include <stdlib.h> |
---|
24 | |
---|
25 | #include "gmp.h" |
---|
26 | #include "gmp-impl.h" |
---|
27 | #include "tests.h" |
---|
28 | |
---|
29 | /* Check mpz_gcd_ui doesn't try to return a value out of range. |
---|
30 | This was wrong in gmp 4.1.2 with a long long limb. */ |
---|
31 | static void |
---|
32 | check_ui_range (void) |
---|
33 | { |
---|
34 | unsigned long got; |
---|
35 | mpz_t x; |
---|
36 | int i; |
---|
37 | |
---|
38 | mpz_init_set_ui (x, ULONG_MAX); |
---|
39 | |
---|
40 | for (i = 0; i < 20; i++) |
---|
41 | { |
---|
42 | mpz_mul_2exp (x, x, 1L); |
---|
43 | got = mpz_gcd_ui (NULL, x, 0L); |
---|
44 | if (got != 0) |
---|
45 | { |
---|
46 | printf ("mpz_gcd_ui (ULONG_MAX*2^%d, 0)\n", i); |
---|
47 | printf (" return %#lx\n", got); |
---|
48 | printf (" should be 0\n"); |
---|
49 | abort (); |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | mpz_clear (x); |
---|
54 | } |
---|
55 | |
---|
56 | int |
---|
57 | main (void) |
---|
58 | { |
---|
59 | tests_start (); |
---|
60 | |
---|
61 | check_ui_range (); |
---|
62 | |
---|
63 | tests_end (); |
---|
64 | exit (0); |
---|
65 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.