(root)/
glibc-2.38/
stdio-common/
tllformat.c
       1  #include <stdio.h>
       2  #include <string.h>
       3  
       4  /* The original file was tiformat.c and it has been changed for long long tests\
       5  . */
       6  typedef struct
       7  {
       8    int line;
       9    long long int value;
      10    const char *result;
      11    const char *format_string;
      12  } sprint_int_type;
      13  
      14  sprint_int_type sprint_ints[] =
      15  {
      16    {__LINE__, 0x00000000ULL,             "0", "%llx"},
      17    {__LINE__, 0xffff00000000208bULL,     "ffff00000000208b", "%llx"},
      18    {__LINE__, 0xffff00000000208bULL,     "18446462598732849291", "%llu"},
      19    {__LINE__, 18446462598732849291ULL,   "ffff00000000208b", "%llx"},
      20    {__LINE__, 18446462598732849291ULL,   "18446462598732849291", "%llu"},
      21    {__LINE__, 18359476226655002763ULL,   "fec9f65b0000208b", "%llx"},
      22    {__LINE__, 18359476226655002763ULL,   "18359476226655002763", "%llu"},
      23  
      24    {0},
      25  };
      26  
      27  int
      28  main (void)
      29  {
      30    int errcount = 0;
      31    int testcount = 0;
      32  #define BSIZE 1024
      33    char buffer[BSIZE];
      34    sprint_int_type *iptr;
      35    for (iptr = sprint_ints; iptr->line; iptr++)
      36      {
      37        sprintf (buffer, iptr->format_string, iptr->value);
      38        if (strcmp (buffer, iptr->result) != 0)
      39  	{
      40  	  ++errcount;
      41  	  printf ("\
      42  Error in line %d using \"%s\".  Result is \"%s\"; should be: \"%s\".\n",
      43  		  iptr->line, iptr->format_string, buffer, iptr->result);
      44          }
      45        ++testcount;
      46      }
      47  
      48    if (errcount == 0)
      49      {
      50        printf ("Encountered no errors in %d tests.\n", testcount);
      51        return 0;
      52      }
      53    else
      54      {
      55        printf ("Encountered %d errors in %d tests.\n",
      56  	      errcount, testcount);
      57        return 1;
      58      }
      59  }