diff options
author | Kevin Ryde <user42@zip.com.au> | 2003-03-29 00:19:40 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2003-03-29 00:19:40 +0100 |
commit | e84be16bd8a72761897737c84f446f3e45462878 (patch) | |
tree | a683357a60426f3e18922b062c087a94ab991230 /tests/misc.c | |
parent | 62d2fd3454539dacc3322ea3edc9e2418b90f48d (diff) | |
download | gmp-e84be16bd8a72761897737c84f446f3e45462878.tar.gz |
* tests/misc.c, tests/tests.h (call_rand_algs): New function.
Diffstat (limited to 'tests/misc.c')
-rw-r--r-- | tests/misc.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/tests/misc.c b/tests/misc.c index a318b1f27..36fb70b8c 100644 --- a/tests/misc.c +++ b/tests/misc.c @@ -1,6 +1,6 @@ /* Miscellaneous test program support routines. -Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -360,3 +360,48 @@ urandom (void) return n[0] + (n[1] << GMP_NUMB_BITS); #endif } + + +/* Call (*func)() with various random number generators. */ +void +call_rand_algs (void (*func) __GMP_PROTO ((const char *, gmp_randstate_ptr))) +{ + gmp_randstate_t rstate; + mpz_t a; + + mpz_init (a); + + gmp_randinit_default (rstate); + (*func) ("gmp_randinit_default", rstate); + gmp_randclear (rstate); + + gmp_randinit_mt (rstate); + (*func) ("gmp_randinit_mt", rstate); + gmp_randclear (rstate); + + gmp_randinit_lc_2exp_size (rstate, 8L); + (*func) ("gmp_randinit_lc_2exp_size 8", rstate); + gmp_randclear (rstate); + + gmp_randinit_lc_2exp_size (rstate, 16L); + (*func) ("gmp_randinit_lc_2exp_size 16", rstate); + gmp_randclear (rstate); + + gmp_randinit_lc_2exp_size (rstate, 128L); + (*func) ("gmp_randinit_lc_2exp_size 128", rstate); + gmp_randclear (rstate); + + /* degenerate always zeros */ + mpz_set_ui (a, 0L); + gmp_randinit_lc_2exp (rstate, a, 0L, 8L); + (*func) ("gmp_randinit_lc_2exp a=0 c=0 m=8", rstate); + gmp_randclear (rstate); + + /* degenerate always FFs */ + mpz_set_ui (a, 0L); + gmp_randinit_lc_2exp (rstate, a, 0xFFL, 8L); + (*func) ("gmp_randinit_lc_2exp a=0 c=0xFF m=8", rstate); + gmp_randclear (rstate); + + mpz_clear (a); +} |