about summary refs log tree commit diff
path: root/localedata/tst-fmon.c
blob: 4b7146996e07b43e763eaeb415405f78fafb8612 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <monetary.h>
#include <stdio.h>
#include <locale.h>

static int
check (const char *fmt, double n)
{
  int result;
  char buf[1000];

  result = strfmon (buf, sizeof buf, fmt, n) == -1;

  printf ("\"%s\"\n", buf);
  return result;
}

int
main (void)
{
  int result = 0;

  setlocale (LC_ALL, "");

  result |= check ("%n", 123.45);
  result |= check ("%n", -123.45);
  result |= check ("%n", 3456.781);

  result |= check ("%11n", 123.45);
  result |= check ("%11n", -123.45);
  result |= check ("%11n", 3456.781);

  result |= check ("%#5n", 123.45);
  result |= check ("%#5n", -123.45);
  result |= check ("%#5n", 3456.781);

  result |= check ("%=*#5n", 123.45);
  result |= check ("%=*#5n", -123.45);
  result |= check ("%=*#5n", 3456.781);

  result |= check ("%=0#5n", 123.45);
  result |= check ("%=0#5n", -123.45);
  result |= check ("%=0#5n", 3456.781);

  result |= check ("%^#5n", 123.45);
  result |= check ("%^#5n", -123.45);
  result |= check ("%^#5n", 3456.781);

  result |= check ("%^#5.0n", 123.45);
  result |= check ("%^#5.0n", -123.45);
  result |= check ("%^#5.0n", 3456.781);

  result |= check ("%^#5.4n", 123.45);
  result |= check ("%^#5.4n", -123.45);
  result |= check ("%^#5.4n", 3456.781);

  result |= check ("%(#5n", 123.45);
  result |= check ("%(#5n", -123.45);
  result |= check ("%(#5n", 3456.781);

  result |= check ("%!(#5n", 123.45);
  result |= check ("%!(#5n", -123.45);
  result |= check ("%!(#5n", 3456.781);

  return result;
}