summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTorbjorn Granlund <tege@gmplib.org>2012-01-30 16:30:26 +0100
committerTorbjorn Granlund <tege@gmplib.org>2012-01-30 16:30:26 +0100
commit8d49dafc7c996ee3cb08195521e7b8bc49a90b7d (patch)
tree3fd0f5f3fd5f9a7c4cf7ca231a2cffaf456c56e3 /tests
parent177db79b92db576b2c3f6ec5c8bcf5091907eebe (diff)
downloadgmp-8d49dafc7c996ee3cb08195521e7b8bc49a90b7d.tar.gz
Ensure all sizes are seen.
Diffstat (limited to 'tests')
-rw-r--r--tests/mpz/t-powm.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/mpz/t-powm.c b/tests/mpz/t-powm.c
index 3e4884724..b14d0984c 100644
--- a/tests/mpz/t-powm.c
+++ b/tests/mpz/t-powm.c
@@ -1,6 +1,6 @@
/* Test mpz_powm, mpz_mul, mpz_mod, mpz_mod_ui, mpz_div_ui.
-Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2009 Free Software
+Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2009, 2012 Free Software
Foundation, Inc.
This file is part of the GNU MP Library.
@@ -20,6 +20,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "gmp.h"
#include "gmp-impl.h"
@@ -27,6 +28,21 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
void debug_mp __GMP_PROTO ((mpz_t, int));
+#define SIZEM 13
+
+/* Check that all sizes up to just above MUL_TOOM22_THRESHOLD have been tested
+ a few times. FIXME: If SIZEM is set too low, this will never happen. */
+int
+allsizes_seen (int *allsizes)
+{
+ mp_size_t i;
+
+ for (i = 1; i < MUL_TOOM22_THRESHOLD + 4; i++)
+ if (allsizes[i] < 4)
+ return 0;
+ return 1;
+}
+
int
main (int argc, char **argv)
{
@@ -38,6 +54,7 @@ main (int argc, char **argv)
gmp_randstate_ptr rands;
mpz_t bs;
unsigned long bsi, size_range;
+ unsigned int allsizes[1 << (SIZEM + 2 - 1)];
tests_start ();
TESTS_REPS (reps, argv, argc);
@@ -55,10 +72,12 @@ main (int argc, char **argv)
mpz_init (exp2);
mpz_init (base2);
- for (i = 0; i < reps; i++)
+ memset (allsizes, 0, (1 << (SIZEM + 2 - 1)) * sizeof (int));
+
+ for (i = 0; i < reps || ! allsizes_seen (allsizes); i++)
{
mpz_urandomb (bs, rands, 32);
- size_range = mpz_get_ui (bs) % 13 + 2;
+ size_range = mpz_get_ui (bs) % SIZEM + 2;
do /* Loop until mathematically well-defined. */
{
@@ -80,6 +99,8 @@ main (int argc, char **argv)
}
while (mpz_cmp_ui (mod, 0) == 0);
+ allsizes[SIZ(mod)] += 1;
+
mpz_urandomb (bs, rands, 2);
bsi = mpz_get_ui (bs);
if ((bsi & 1) != 0)