3 Copyright 2001 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
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 3 of the License, or (at your
10 option) any later version.
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.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
28 check_one (mpq_srcptr x, mpq_srcptr y, int want)
35 got = mpq_equal (x, y);
36 if ((got != 0) != (want != 0))
38 printf ("mpq_equal got %d want %d\n", got, want);
47 check_all (mpq_ptr x, mpq_ptr y, int want)
49 check_one (x, y, want);
50 check_one (y, x, want);
55 check_one (x, y, want);
56 check_one (y, x, want);
60 #define SET4Z(z, size,l3,l2,l1,l0) \
61 SIZ(z) = size; PTR(z)[3] = l3; PTR(z)[2] = l2; PTR(z)[1] = l1; PTR(z)[0] = l0
63 #define SET4(q, nsize,n3,n2,n1,n0, dsize,d3,d2,d1,d0) \
64 SET4Z (mpq_numref(q), nsize,n3,n2,n1,n0); \
65 SET4Z (mpq_denref(q), dsize,d3,d2,d1,d0)
68 /* Exercise various combinations of same and slightly different values. */
78 mpz_realloc (mpq_numref(x), (mp_size_t) 20);
79 mpz_realloc (mpq_denref(x), (mp_size_t) 20);
80 mpz_realloc (mpq_numref(y), (mp_size_t) 20);
81 mpz_realloc (mpq_denref(y), (mp_size_t) 20);
84 SET4 (x, 0,13,12,11,10, 1,23,22,21,1);
85 SET4 (y, 0,33,32,31,30, 1,43,42,41,1);
89 SET4 (x, 1,13,12,11,83, 1,23,22,21,99);
90 SET4 (y, 1,33,32,31,83, 1,43,42,41,99);
93 /* 1:2:3:4/5:6:7 == 1:2:3:4/5:6:7 */
94 SET4 (x, 4,1,2,3,4, 3,88,5,6,7);
95 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
98 /* various individual changes making != */
99 SET4 (x, 4,1,2,3,667, 3,88,5,6,7);
100 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
102 SET4 (x, 4,1,2,666,4, 3,88,5,6,7);
103 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
105 SET4 (x, 4,1,666,3,4, 3,88,5,6,7);
106 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
108 #if GMP_NUMB_BITS != 62
109 SET4 (x, 4,667,2,3,4, 3,88,5,6,7);
110 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
113 SET4 (x, 4,1,2,3,4, 3,88,5,6,667);
114 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
116 SET4 (x, 4,1,2,3,4, 3,88,5,667,7);
117 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
119 SET4 (x, 4,1,2,3,4, 3,88,666,6,7);
120 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
122 SET4 (x, -4,1,2,3,4, 3,88,5,6,7);
123 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);
125 SET4 (x, 1,1,2,3,4, 3,88,5,6,7);
126 SET4 (y, 4,1,2,3,4, 3,99,5,6,7);