]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - stdlib/tst-strtod-nan-locale-main.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / stdlib / tst-strtod-nan-locale-main.c
index 84a46904a103ad34e55aeef9b88d97d611fd47cf..bc44baf0cc87fa156cd9759f0a67fddd43465651 100644 (file)
@@ -1,6 +1,6 @@
 /* Test strtod functions work with all ASCII letters in NAN(...) in
    Turkish locales (bug 19266).
-   Copyright (C) 2015 Free Software Foundation, Inc.
+   Copyright (C) 2015-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -23,6 +23,8 @@
 #include <stdlib.h>
 #include <wchar.h>
 
+#include <stdlib/tst-strtod.h>
+
 #define STR_(X) #X
 #define STR(X) STR_(X)
 #define FNPFXS STR (FNPFX)
 #define CONCAT(X, Y) CONCAT_ (X, Y)
 #define FNX(FN) CONCAT (FNPFX, FN)
 
-#define TEST(LOC, STR, FN, TYPE)                                       \
-  do                                                                   \
+#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF)                   \
+static int                                                             \
+test_strto ## FSUF (const char * loc, CHAR * s)                                \
+{                                                                      \
+  CHAR *ep;                                                            \
+  FTYPE val = FNX (FSUF) (s, &ep);                                     \
+  if (isnan (val) && *ep == 0)                                         \
+    printf ("PASS: %s: " FNPFXS #FSUF " (" SFMT ")\n", loc, s);                \
+  else                                                                 \
     {                                                                  \
-      CHAR *ep;                                                                \
-      TYPE val = FNX (FN) (STR, &ep);                                  \
-      if (isnan (val) && *ep == 0)                                     \
-       printf ("PASS: %s: " FNPFXS #FN " (" SFMT ")\n", LOC, STR);     \
-      else                                                             \
-       {                                                               \
-         printf ("FAIL: %s: " FNPFXS #FN " (" SFMT ")\n", LOC, STR);   \
-         result = 1;                                                   \
-       }                                                               \
+      printf ("FAIL: %s: " FNPFXS #FSUF " (" SFMT ")\n", loc, s);      \
+      return 1;                                                                \
     }                                                                  \
-  while (0)
+  return 0;                                                            \
+}
+GEN_TEST_STRTOD_FOREACH (TEST_STRTOD)
 
 static int
 test_one_locale (const char *loc)
@@ -64,13 +68,9 @@ test_one_locale (const char *loc)
       s[4] = L_('A') + i - 10;
       s[5] = L_(')');
       s[6] = 0;
-      TEST (loc, s, f, float);
-      TEST (loc, s, d, double);
-      TEST (loc, s, ld, long double);
+      result |= STRTOD_TEST_FOREACH (test_strto, loc, s);
       s[4] = L_('a') + i - 10;
-      TEST (loc, s, f, float);
-      TEST (loc, s, d, double);
-      TEST (loc, s, ld, long double);
+      result |= STRTOD_TEST_FOREACH (test_strto, loc, s);
     }
   return result;
 }