(linenum→info "unix/slp.c:2238")

glibc/2.7/localedata/tst-strfmon1.c

    1: #include <monetary.h>
    2: #include <locale.h>
    3: #include <stdio.h>
    4: #include <string.h>
    5: 
    6: static const struct
    7: {
    8:   const char *locale;
    9:   const char *expected;
   10: } tests[] =
   11:   {
   12:     { "de_DE.ISO-8859-1", "|-12,34 EUR|-12,34|" },
   13:     { "da_DK.ISO-8859-1", "|kr -12,34|-12,34|" },
   14:     { "zh_TW.EUC-TW", "|-NT$12.34|-12.34|" },
   15:     { "sv_SE.ISO-8859-1", "|-12,34 kr|-12,34|" }
   16:   };
   17: #define ntests (sizeof (tests) / sizeof (tests[0]))
   18: 
   19: 
   20: static int
   21: do_test (void)
   22: {
   23:   int res = 0;
   24:   for (int i = 0; i < ntests; ++i)
   25:     {
   26:       char buf[500];
   27:       if (setlocale (LC_ALL, tests[i].locale) == NULL)
   28:         {
   29:           printf ("failed to set locale %s\n", tests[i].locale);
   30:           res = 1;
   31:           continue;
   32:         }
   33:       strfmon (buf, sizeof (buf), "|%n|%!n|", -12.34, -12.34);
   34:       int fail = strcmp (buf, tests[i].expected) != 0;
   35:       printf ("%s%s\n", buf, fail ? " *** FAIL ***" : "");
   36:       res |= fail;
   37:     }
   38:   return res;
   39: }
   40: 
   41: #define TEST_FUNCTION do_test ()
   42: #include "../test-skeleton.c"
Syntax (Markdown)