Blame stdlib/bug-strtod2.c

Packit 6c4009
#include <locale.h>
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
Packit 6c4009
#include "tst-strtod.h"
Packit 6c4009
Packit 6c4009
static const char *tests[] =
Packit 6c4009
  {
Packit 6c4009
    "inf", "Inf", "iNf", "inF", "INf", "iNF", "INF", "InF",
Packit 6c4009
    "infinity", "Infinity", "InfInity", "INFINITY"
Packit 6c4009
  };
Packit 6c4009
#define ntests (sizeof (tests) / sizeof (tests[0]))
Packit 6c4009
Packit 6c4009
#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF)			\
Packit 6c4009
static int								\
Packit 6c4009
test_strto ## FSUF (void)						\
Packit 6c4009
{									\
Packit 6c4009
  int res = 0;								\
Packit 6c4009
  for (int i = 0; i < ntests; ++i)					\
Packit 6c4009
    {									\
Packit 6c4009
      char *endp;							\
Packit 6c4009
      FTYPE d = strto ## FSUF (tests[i], &endp);			\
Packit 6c4009
      if (*endp != '\0')						\
Packit 6c4009
	{								\
Packit 6c4009
	  printf ("did not consume all of '%s'\n", tests[i]);		\
Packit 6c4009
	  res = 1;							\
Packit 6c4009
	}								\
Packit 6c4009
      if (!isinf (d))							\
Packit 6c4009
	{								\
Packit 6c4009
	  printf ("'%s' does not pass isinf\n", tests[i]);		\
Packit 6c4009
	  res = 1;							\
Packit 6c4009
	}								\
Packit 6c4009
    }									\
Packit 6c4009
									\
Packit 6c4009
  return res;								\
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
GEN_TEST_STRTOD_FOREACH (TEST_STRTOD)
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  /* The Turkish locale is notorious because tolower() maps 'I' to the
Packit 6c4009
     dotless lowercase 'i' and toupper() maps 'i' to an 'I' with a dot
Packit 6c4009
     above.  */
Packit 6c4009
  if (setlocale (LC_ALL, "tr_TR.UTF-8") == NULL)
Packit 6c4009
    {
Packit 6c4009
      puts ("cannot set locale");
Packit 6c4009
      return 0;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  return STRTOD_TEST_FOREACH (test_strto);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define TEST_FUNCTION do_test ()
Packit 6c4009
#include "../test-skeleton.c"