Blame localedata/tst-strfmon1.c

Packit 6c4009
#include <monetary.h>
Packit 6c4009
#include <locale.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <string.h>
Packit 6c4009
Packit 6c4009
static const struct
Packit 6c4009
{
Packit 6c4009
  const char *locale;
Packit 6c4009
  const char *expected;
Packit 6c4009
} tests[] =
Packit 6c4009
  {
Packit 6c4009
    { "de_DE.ISO-8859-1", "|-12,34 EUR|-12,34|" },
Packit 6c4009
    { "da_DK.ISO-8859-1", "|kr. -12,34|-12,34|" },
Packit 6c4009
    { "zh_TW.EUC-TW", "|-NT$12.34|-12.34|" },
Packit 6c4009
    { "sv_SE.ISO-8859-1", "|-12,34 kr|-12,34|" }
Packit 6c4009
  };
Packit 6c4009
#define ntests (sizeof (tests) / sizeof (tests[0]))
Packit 6c4009
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  int res = 0;
Packit 6c4009
  for (int i = 0; i < ntests; ++i)
Packit 6c4009
    {
Packit 6c4009
      char buf[500];
Packit 6c4009
      if (setlocale (LC_ALL, tests[i].locale) == NULL)
Packit 6c4009
	{
Packit 6c4009
	  printf ("failed to set locale %s\n", tests[i].locale);
Packit 6c4009
	  res = 1;
Packit 6c4009
	  continue;
Packit 6c4009
	}
Packit 6c4009
      strfmon (buf, sizeof (buf), "|%n|%!n|", -12.34, -12.34);
Packit 6c4009
      int fail = strcmp (buf, tests[i].expected) != 0;
Packit 6c4009
      printf ("%s%s\n", buf, fail ? " *** FAIL ***" : "");
Packit 6c4009
      res |= fail;
Packit 6c4009
    }
Packit 6c4009
  return res;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define TEST_FUNCTION do_test ()
Packit 6c4009
#include "../test-skeleton.c"