]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Refactor bug-strtod2.c to be type generic
authorPaul E. Murphy <murphyp@linux.vnet.ibm.com>
Fri, 6 May 2016 21:13:29 +0000 (16:13 -0500)
committerPaul E. Murphy <murphyp@linux.vnet.ibm.com>
Mon, 23 May 2016 19:13:11 +0000 (14:13 -0500)
This only tested for strtod. This expands the testing to
all variants of strto*.

ChangeLog
stdlib/bug-strtod2.c

index de34b56c9dd804fa68b19462bf0cd4c98d299eb7..d75680389fa89c0e67caec7a76a3ef4436be5a87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-05-23  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
+
+       * stdlib/bug-strtod2.c (do_test): Refactor strtod usage into ...
+       (TEST_STRTOD): New macro.
+       (TEST_FUNCTION): Redefine to use STRTOD_TEST_FOREACH
+
 2016-05-23  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
 
        * stdlib/tst-strtod6.c (do_test): Use new type generic
index a1f037cdc8d611b1dabf74cbfad7b36649f0ccce..cd13e9aa5beae5d9d77798cf68d63841fa943d84 100644 (file)
@@ -3,6 +3,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "tst-strtod.h"
+
 static const char *tests[] =
   {
     "inf", "Inf", "iNf", "inF", "INf", "iNF", "INF", "InF",
@@ -10,6 +12,32 @@ static const char *tests[] =
   };
 #define ntests (sizeof (tests) / sizeof (tests[0]))
 
+#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF)          \
+static int                                                             \
+test_strto ## FSUF (void)                                              \
+{                                                                      \
+  int res = 0;                                                         \
+  for (int i = 0; i < ntests; ++i)                                     \
+    {                                                                  \
+      char *endp;                                                      \
+      FTYPE d = strto ## FSUF (tests[i], &endp);                       \
+      if (*endp != '\0')                                               \
+       {                                                               \
+         printf ("did not consume all of '%s'\n", tests[i]);           \
+         res = 1;                                                      \
+       }                                                               \
+      if (!isinf (d))                                                  \
+       {                                                               \
+         printf ("'%s' does not pass isinf\n", tests[i]);              \
+         res = 1;                                                      \
+       }                                                               \
+    }                                                                  \
+                                                                       \
+  return res;                                                          \
+}
+
+GEN_TEST_STRTOD_FOREACH (TEST_STRTOD)
+
 static int
 do_test (void)
 {
@@ -22,24 +50,7 @@ do_test (void)
       return 0;
     }
 
-  int res = 0;
-  for (int i = 0; i < ntests; ++i)
-    {
-      char *endp;
-      double d = strtod (tests[i], &endp);
-      if (*endp != '\0')
-       {
-         printf ("did not consume all of '%s'\n", tests[i]);
-         res = 1;
-       }
-      if (!isinf (d))
-       {
-         printf ("'%s' does not pass isinf\n", tests[i]);
-         res = 1;
-       }
-    }
-
-  return res;
+  return STRTOD_TEST_FOREACH (test_strto);
 }
 
 #define TEST_FUNCTION do_test ()