Back to index

glibc  2.9
Defines | Functions | Variables
tst-xlocale1.c File Reference
#include <locale.h>
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Defines

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

Functions

int main (void)

Variables

struct {
const char * locale
const char * str1
const char * str2
int result
tests []

Define Documentation

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

Definition at line 20 of file tst-xlocale1.c.


Function Documentation

int main ( void  )

Definition at line 24 of file tst-xlocale1.c.

{
  size_t cnt;
  int result = 0;
  locale_t loc = newlocale (1 << LC_ALL, "C", NULL);

  for (cnt = 0; cnt < ntests; ++cnt)
    {
      int r;

      if (setlocale (LC_ALL, tests[cnt].locale) == NULL)
       {
         printf ("cannot set locale \"%s\": %m\n", tests[cnt].locale);
         result = 1;
         continue;
       }

      printf ("\nstrcasecmp_l (\"%s\", \"%s\", loc)\n",
             tests[cnt].str1, tests[cnt].str2);

      r = strcasecmp_l (tests[cnt].str1, tests[cnt].str2, loc);
      if (tests[cnt].result == 0)
       {
         if (r != 0)
           {
             printf ("\"%s\" and \"%s\" expected to be the same, result %d\n",
                    tests[cnt].str1, tests[cnt].str2, r);
             result = 1;
           }
       }
      else if (tests[cnt].result < 0)
       {
         if (r >= 0)
           {
             printf ("\"%s\" expected to be smaller than \"%s\", result %d\n",
                    tests[cnt].str1, tests[cnt].str2, r);
             result = 1;
           }
       }
      else
       {
         if (r <= 0)
           {
             printf ("\"%s\" expected to be larger than \"%s\", result %d\n",
                    tests[cnt].str1, tests[cnt].str2, r);
             result = 1;
           }
       }
    }

  return result;
}

Here is the call graph for this function:


Variable Documentation

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