Back to index

glibc  2.9
Defines | Functions | Variables
tst-strtod5.c File Reference
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define NBSP   "\xc2\xa0"
#define NTESTS   (sizeof (tests) / sizeof (tests[0]))
#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Variables

struct {
const char * in
int group
double expected
tests []

Define Documentation

#define NBSP   "\xc2\xa0"

Definition at line 7 of file tst-strtod5.c.

#define NTESTS   (sizeof (tests) / sizeof (tests[0]))

Definition at line 45 of file tst-strtod5.c.

#define TEST_FUNCTION   do_test ()

Definition at line 87 of file tst-strtod5.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 49 of file tst-strtod5.c.

{
  if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL)
    {
      puts ("could not set locale");
      return 1;
    }

  int status = 0;

  for (int i = 0; i < NTESTS; ++i)
    {
      char *ep;
      double r;

      if (tests[i].group)
       r = __strtod_internal (tests[i].in, &ep, 1);
      else
       r = strtod (tests[i].in, &ep);

      if (*ep != '\0')
       {
         printf ("%d: got rest string \"%s\", expected \"\"\n", i, ep);
         status = 1;
       }

      if (r != tests[i].expected
         || copysign (10.0, r) != copysign (10.0, tests[i].expected))
       {
         printf ("%d: got wrong results %g, expected %g\n",
                i, r, tests[i].expected);
         status = 1;
       }
    }

  return status;
}

Here is the call graph for this function:


Variable Documentation

struct { ... } tests[] [static]