1 /* Test gmp_urandomm_ui.
3 Copyright 2003, 2005 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/. */
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);