[Gmp-commit] /var/hg/gmp: tests/devel/sqrtrem_1_2.c (main): Interface improve...

mercurial at gmplib.org mercurial at gmplib.org
Sun Apr 2 04:14:46 UTC 2017


details:   /var/hg/gmp/rev/c32d616089b4
changeset: 17341:c32d616089b4
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Apr 02 06:14:40 2017 +0200
description:
tests/devel/sqrtrem_1_2.c (main): Interface improvement.

diffstat:

 tests/devel/sqrtrem_1_2.c |  27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diffs (77 lines):

diff -r 61eb6b13cf77 -r c32d616089b4 tests/devel/sqrtrem_1_2.c
--- a/tests/devel/sqrtrem_1_2.c	Thu Mar 30 18:22:38 2017 +0200
+++ b/tests/devel/sqrtrem_1_2.c	Sun Apr 02 06:14:40 2017 +0200
@@ -57,7 +57,7 @@
 }
 
 int
-check_all_values ()
+check_all_values (int justone)
 {
   mp_limb_t es, mer, er, s[1], r[2], q[2];
   mp_size_t x;
@@ -86,7 +86,9 @@
   } while (*q != 0);
   q[1] = 1;
   SPINNER(2);
-  printf ("\nValues of a single limb, tested.\nAll values tested, up to bits:\n");
+  printf ("\nValues of a single limb, tested.\n");
+  if (justone) return 0;
+  printf ("All values tested, up to bits:\n");
   do {
     x = mpn_sqrtrem (s, r, q, 2);
     if (UNLIKELY (x != (er != 0)) || UNLIKELY (*s != es)
@@ -112,7 +114,7 @@
 }
 
 int
-check_corner_cases ()
+check_corner_cases (int justone)
 {
   mp_limb_t es, er, s[1], r[2], q[2];
   mp_size_t x;
@@ -141,7 +143,9 @@
   } while (*q != 0);
   q[1] = 1;
   SPINNER(2);
-  printf ("\nValues of a single limb, tested.\nCorner cases tested, up to bits:\n");
+  printf ("\nValues of a single limb, tested.\n");
+  if (justone) return 0;
+  printf ("Corner cases tested, up to bits:\n");
   do {
     x = mpn_sqrtrem (s, r, q, 2);
     if (UNLIKELY (x != (er != 0)) || UNLIKELY (*s != es)
@@ -200,24 +204,27 @@
 main (int argc, char **argv)
 {
   int mode = 0;
+  int justone = 0;
 
-  if (argc > 1)
+  for (;argc > 1;--argc,++argv)
     {
       if (*argv[1] == 'x')
 	mode = 0;
       else if (*argv[1] == 'c')
 	mode = 1;
+      else if (*argv[1] == '1')
+	justone = 1;
+      else if (*argv[1] == '2')
+	justone = 0;
       else
-	mode = -1;
-      if (argc > 2 || mode == -1)
 	{
-	  fprintf (stderr, "usage: sqrtrem_1_2 [x|c]\n");
+	  fprintf (stderr, "usage: sqrtrem_1_2 [x|c] [1|2]\n");
 	  exit (1);
 	}
     }
 
   if (mode == 0)
-    return check_all_values ();
+    return check_all_values (justone);
   else
-    return check_corner_cases ();
+    return check_corner_cases (justone);
 }


More information about the gmp-commit mailing list