1 /* Test mpn_scan0 and mpn_scan1.
3 Copyright 2002 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library test suite.
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.
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.
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/. */
29 #define SIZE ((mp_size_t) 3)
35 unsigned long i, got, want;
38 for (i = 0; i < SIZE*GMP_NUMB_BITS; i++)
40 got = refmpn_scan1 (x, i);
41 want = mpn_scan1 (x, i);
44 printf ("mpn_scan1\n");
45 printf (" i %lu\n", i);
46 printf (" got %lu\n", got);
47 printf (" want %lu\n", want);
48 mpn_trace (" x ", x, SIZE);
54 for (i = 0; i < SIZE*GMP_NUMB_BITS; i++)
56 got = refmpn_scan0 (x, i);
57 want = mpn_scan0 (x, i);
60 printf ("mpn_scan0\n");
61 printf (" i %lu\n", i);
62 printf (" got %lu\n", got);
63 printf (" want %lu\n", want);
64 mpn_trace (" x ", x, SIZE);
73 #define TWOBITS(a, b) \
74 ((CNST_LIMB(1) << (a)) | (CNST_LIMB(1) << (b)))
76 refmpn_zero (x, SIZE);
77 x[0] = TWOBITS (1, 0);
80 refmpn_zero (x, SIZE);
81 x[0] = TWOBITS (GMP_NUMB_BITS-1, 1);
84 refmpn_zero (x, SIZE);
89 refmpn_zero (x, SIZE);
90 x[0] = CNST_LIMB(1) << (GMP_NUMB_BITS-1);
94 refmpn_zero (x, SIZE);
95 x[1] = TWOBITS (1, 0);
98 refmpn_zero (x, SIZE);
104 /* This is unused, it takes too long, especially on 64-bit systems. */
106 check_twobits_exhaustive (void)
110 for (i = 0; i < GMP_NUMB_BITS * SIZE; i++)
112 for (j = 0; j < GMP_NUMB_BITS * SIZE; j++)
114 refmpn_zero (x, SIZE);
115 refmpn_setbit (x, i);
116 refmpn_setbit (x, j);
127 for (i = 0; i < 100; i++)
129 refmpn_random2 (x, SIZE);