[Gmp-commit] /var/hg/gmp: mini-gmp: New file testutils.c, defining a shared m...
mercurial at gmplib.org
mercurial at gmplib.org
Fri Jan 18 21:15:29 CET 2013
details: /var/hg/gmp/rev/8794a8f80fc0
changeset: 15303:8794a8f80fc0
user: Niels M?ller <nisse at lysator.liu.se>
date: Fri Jan 18 21:15:02 2013 +0100
description:
mini-gmp: New file testutils.c, defining a shared main function.
Each test program now defines testmain rather than main.
diffstat:
ChangeLog | 10 ++++++++++
mini-gmp/tests/Makefile | 5 ++---
mini-gmp/tests/t-add.c | 10 +++-------
mini-gmp/tests/t-bitops.c | 10 +++-------
mini-gmp/tests/t-comb.c | 8 +++-----
mini-gmp/tests/t-div.c | 10 +++-------
mini-gmp/tests/t-div_2exp.c | 10 +++-------
mini-gmp/tests/t-double.c | 9 +++------
mini-gmp/tests/t-gcd.c | 10 +++-------
mini-gmp/tests/t-import.c | 10 +++-------
mini-gmp/tests/t-invert.c | 10 +++-------
mini-gmp/tests/t-lcm.c | 10 +++-------
mini-gmp/tests/t-logops.c | 10 +++-------
mini-gmp/tests/t-mul.c | 10 +++-------
mini-gmp/tests/t-powm.c | 10 +++-------
mini-gmp/tests/t-reuse.c | 10 +++-------
mini-gmp/tests/t-root.c | 10 +++-------
mini-gmp/tests/t-scan.c | 10 +++-------
mini-gmp/tests/t-signed.c | 8 +++-----
mini-gmp/tests/t-sqrt.c | 10 +++-------
mini-gmp/tests/t-str.c | 10 +++-------
mini-gmp/tests/t-sub.c | 10 +++-------
mini-gmp/tests/testutils.c | 35 +++++++++++++++++++++++++++++++++++
mini-gmp/tests/testutils.h | 22 ++++++++++++++++++++++
24 files changed, 129 insertions(+), 138 deletions(-)
diffs (truncated from 826 to 300 lines):
diff -r 85673dea939f -r 8794a8f80fc0 ChangeLog
--- a/ChangeLog Fri Jan 18 19:46:14 2013 +0100
+++ b/ChangeLog Fri Jan 18 21:15:02 2013 +0100
@@ -1,3 +1,13 @@
+2013-01-18 Niels Möller <nisse at lysator.liu.se>
+
+ * mini-gmp/tests/testutils.h: New file, declarations for test
+ programs.
+
+ * mini-gmp/tests/testutils.c (main): New file, with shared main
+ function for all the test programs. Also includes mini-gmp.c.
+ Calls testmain after initialization. All other test programs
+ updated to define testmain rather than main.
+
2013-01-18 Torbjorn Granlund <tege at gmplib.org>
* mini-gmp/tests/t-div.c: Test also mpz_mod, mpz_mod_ui. Compare
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/Makefile
--- a/mini-gmp/tests/Makefile Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/Makefile Fri Jan 18 21:15:02 2013 +0100
@@ -32,7 +32,7 @@
t-sqrt t-root t-powm t-logops t-bitops t-scan t-str \
t-reuse
-MISC_OBJS = hex-random.o mini-random.o mini-gmp.o
+MISC_OBJS = hex-random.o mini-random.o testutils.o
all:
@@ -48,8 +48,7 @@
%.o: %.c $(MINI_GMP_DIR)/mini-gmp.h hex-random.h mini-random.h
$(CC) $(CFLAGS) -c $< -o $@
-mini-gmp.o: $(MINI_GMP_DIR)/mini-gmp.c $(MINI_GMP_DIR)/mini-gmp.h
- $(CC) $(CFLAGS) -c $(MINI_GMP_DIR)/mini-gmp.c -o mini-gmp.o
+testutils.o: $(MINI_GMP_DIR)/mini-gmp.c
%: %.o $(MISC_OBJS)
$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/t-add.c
--- a/mini-gmp/tests/t-add.c Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/t-add.c Fri Jan 18 21:15:02 2013 +0100
@@ -20,7 +20,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include "mini-random.h"
+#include "testutils.h"
#define MAXBITS 400
#define COUNT 10000
@@ -33,14 +33,12 @@
free (buf);
}
-int
-main (int argc, char **argv)
+void
+testmain (int argc, char **argv)
{
unsigned i;
mpz_t a, b, res, ref;
- hex_random_init ();
-
mpz_init (a);
mpz_init (b);
mpz_init (res);
@@ -64,6 +62,4 @@
mpz_clear (b);
mpz_clear (res);
mpz_clear (ref);
-
- return 0;
}
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/t-bitops.c
--- a/mini-gmp/tests/t-bitops.c Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/t-bitops.c Fri Jan 18 21:15:02 2013 +0100
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include "mini-random.h"
+#include "testutils.h"
#define MAXBITS 400
#define COUNT 10000
@@ -34,15 +34,13 @@
free (buf);
}
-int
-main (int argc, char **argv)
+void
+testmain (int argc, char **argv)
{
unsigned i;
mpz_t a, res, ref;
mp_bitcnt_t b;
- hex_random_init ();
-
mpz_init (a);
mpz_init (res);
mpz_init (ref);
@@ -110,6 +108,4 @@
mpz_clear (a);
mpz_clear (res);
mpz_clear (ref);
-
- return 0;
}
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/t-comb.c
--- a/mini-gmp/tests/t-comb.c Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/t-comb.c Fri Jan 18 21:15:02 2013 +0100
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "mini-gmp.h"
+#include "testutils.h"
/* Usage: t-fac_ui [x|num]
@@ -149,8 +149,8 @@
}
-int
-main (int argc, char *argv[])
+void
+testmain (int argc, char *argv[])
{
unsigned long limit = 128;
@@ -162,6 +162,4 @@
checkprimes(1009, 733, 277);
fac_smallexaustive (limit);
bin_smallexaustive (limit);
-
- return 0;
}
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/t-div.c
--- a/mini-gmp/tests/t-div.c Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/t-div.c Fri Jan 18 21:15:02 2013 +0100
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include "mini-random.h"
+#include "testutils.h"
#define MAXBITS 400
#define COUNT 10000
@@ -40,15 +40,13 @@
typedef unsigned long div_x_ui_func (mpz_t, const mpz_t, unsigned long);
typedef unsigned long div_ui_func (const mpz_t, unsigned long);
-int
-main (int argc, char **argv)
+void
+testmain (int argc, char **argv)
{
unsigned i;
mpz_t a, b, q, r, rq, rr;
int div_p;
- hex_random_init ();
-
mpz_init (a);
mpz_init (b);
mpz_init (r);
@@ -261,6 +259,4 @@
mpz_clear (q);
mpz_clear (rr);
mpz_clear (rq);
-
- return 0;
}
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/t-div_2exp.c
--- a/mini-gmp/tests/t-div_2exp.c Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/t-div_2exp.c Fri Jan 18 21:15:02 2013 +0100
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include "mini-random.h"
+#include "testutils.h"
#define MAXBITS 400
#define COUNT 10000
@@ -36,15 +36,13 @@
typedef void div_func (mpz_t, const mpz_t, mp_bitcnt_t);
-int
-main (int argc, char **argv)
+void
+testmain (int argc, char **argv)
{
unsigned i;
mpz_t a, res, ref;
mp_bitcnt_t b;
- hex_random_init ();
-
mpz_init (a);
mpz_init (res);
mpz_init (ref);
@@ -89,6 +87,4 @@
mpz_clear (a);
mpz_clear (res);
mpz_clear (ref);
-
- return 0;
}
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/t-double.c
--- a/mini-gmp/tests/t-double.c Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/t-double.c Fri Jan 18 21:15:02 2013 +0100
@@ -23,7 +23,7 @@
#include <stdio.h>
#include <string.h>
-#include "mini-random.h"
+#include "testutils.h"
#define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)
@@ -55,14 +55,12 @@
{ 0.0, NULL }
};
-int
-main (int argc, char **argv)
+void
+testmain (int argc, char **argv)
{
unsigned i;
mpz_t x;
- hex_random_init ();
-
for (i = 0; values[i].s; i++)
{
char *s;
@@ -143,5 +141,4 @@
}
mpz_clear (x);
- return EXIT_SUCCESS;
}
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/t-gcd.c
--- a/mini-gmp/tests/t-gcd.c Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/t-gcd.c Fri Jan 18 21:15:02 2013 +0100
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include "mini-random.h"
+#include "testutils.h"
#define MAXBITS 400
#define COUNT 10000
@@ -103,14 +103,12 @@
return 1;
}
-int
-main (int argc, char **argv)
+void
+testmain (int argc, char **argv)
{
unsigned i;
mpz_t a, b, g, s, t;
- hex_random_init ();
-
mpz_init (a);
mpz_init (b);
mpz_init (g);
@@ -178,6 +176,4 @@
mpz_clear (g);
mpz_clear (s);
mpz_clear (t);
-
- return 0;
}
diff -r 85673dea939f -r 8794a8f80fc0 mini-gmp/tests/t-import.c
--- a/mini-gmp/tests/t-import.c Fri Jan 18 19:46:14 2013 +0100
+++ b/mini-gmp/tests/t-import.c Fri Jan 18 21:15:02 2013 +0100
@@ -21,7 +21,7 @@
#include <stdio.h>
#include <string.h>
-#include "mini-random.h"
+#include "testutils.h"
#define MAX_WORDS 20
#define MAX_WORD_SIZE 10
@@ -49,8 +49,8 @@
More information about the gmp-commit
mailing list