This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19 #if HAVE_MONETARY_H
20 # include <monetary.h>
21 #endif
22
23 #include "signature.h"
24 #if HAVE_STRFMON_L
25 SIGNATURE_CHECK (strfmon_l, ssize_t, (char *s, size_t maxsize, locale_t locale,
26 const char *format, ...));
27 #endif
28
29 #include <locale.h>
30 #include <stdio.h>
31 #include <string.h>
32
33 #include "macros.h"
34
35 int
36 main (void)
37 {
38 #if HAVE_STRFMON_L
39
40 {
41 char buf[80];
42 locale_t loc;
43 ssize_t ret;
44
45 loc = newlocale (LC_ALL_MASK, "C", NULL);
46 ASSERT (loc != NULL);
47 ret = strfmon_l (buf, sizeof (buf), loc, "%^#5.0n", 123.4);
48 ASSERT ( (ret == 5 && strcmp (buf, " 123") == 0)
49 || (ret == 6 && strcmp (buf, " 123") == 0)
50 || (ret == 7 && strcmp (buf, " 123 ") == 0)
51 );
52 }
53
54
55
56 if (setlocale (LC_ALL, "en_US.UTF-8") == NULL)
57 {
58 fprintf (stderr, "Skipping test: English Unicode locale is not installed\n");
59 return 77;
60 }
61 if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
62 {
63 fprintf (stderr, "Skipping test: English Unicode locale is not installed\n");
64 return 77;
65 }
66 {
67 char expected_buf[80];
68 locale_t loc;
69 char buf[80];
70
71 setlocale (LC_ALL, "en_US.UTF-8");
72 ASSERT (strfmon (expected_buf, sizeof (expected_buf), "%.2n", 123.5) >= 0);
73 setlocale (LC_ALL, "de_DE.UTF-8");
74 loc = newlocale (LC_ALL_MASK, "en_US.UTF-8", NULL);
75 ASSERT (strfmon_l (buf, sizeof (buf), loc, "%.2n", 123.5) >= 0);
76 ASSERT (strcmp (buf, expected_buf) == 0);
77 freelocale (loc);
78 }
79 {
80 char expected_buf[80];
81 locale_t loc;
82 char buf[80];
83
84 setlocale (LC_ALL, "de_DE.UTF-8");
85 ASSERT (strfmon (expected_buf, sizeof (expected_buf), "%.2n", 123.5) >= 0);
86 setlocale (LC_ALL, "en_US.UTF-8");
87 loc = newlocale (LC_ALL_MASK, "de_DE.UTF-8", NULL);
88 ASSERT (strfmon_l (buf, sizeof (buf), loc, "%.2n", 123.5) >= 0);
89 ASSERT (strcmp (buf, expected_buf) == 0);
90 freelocale (loc);
91 }
92 #endif
93
94 return 0;
95 }