Back to index

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

Go to the source code of this file.

Defines

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

Functions

static int do_test (void)

Variables

struct {
const char * str
const char * expected
tests []

Define Documentation

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

Definition at line 31 of file tst-atof2.c.

#define TEST_FUNCTION   do_test ()

Definition at line 54 of file tst-atof2.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 35 of file tst-atof2.c.

{
  int status = 0;

  for (int i = 0; i < NTESTS; ++i)
    {
      char buf[100];
      snprintf (buf, sizeof (buf), "%g", atof (tests[i].str));
      if (strcmp (buf, tests[i].expected) != 0)
       {
         printf ("%d: got \"%s\", expected \"%s\"\n",
                i, buf, tests[i].expected);
         status = 1;
       }
    }

  return status;
}

Here is the call graph for this function:


Variable Documentation

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