1 /* Test gmp_urandomm_ui.
3 Copyright 2003, 2005 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/. */
26 /* Expect numbers generated by rstate to obey the limit requested. */
28 check_one (const char *name, gmp_randstate_ptr rstate)
30 static const unsigned long n_table[] = {
31 1, 2, 3, 4, 5, 6, 7, 8,
38 ULONG_MAX/2-2, ULONG_MAX/2-1, ULONG_MAX/2, ULONG_MAX/2+1, ULONG_MAX/2+2,
40 ULONG_MAX-2, ULONG_MAX-1, ULONG_MAX,
46 for (i = 0; i < numberof (n_table); i++)
50 for (j = 0; j < 5; j++)
52 got = gmp_urandomm_ui (rstate, n);
55 printf ("Return value out of range:\n");
56 printf (" algorithm: %s\n", name);
57 printf (" n: %#lx\n", n);
58 printf (" got: %#lx\n", got);
67 main (int argc, char *argv[])
71 call_rand_algs (check_one);