2 * Copyright (C) 2017-2020 Free Software Foundation, Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 # include <monetary.h>
23 #include "signature.h"
25 SIGNATURE_CHECK (strfmon_l
, ssize_t
, (char *s
, size_t maxsize
, locale_t locale
,
26 const char *format
, ...));
39 /* Simple test in the C locale. */
45 loc
= newlocale (LC_ALL_MASK
, "C", NULL
);
47 ret
= strfmon_l (buf
, sizeof (buf
), loc
, "%^#5.0n", 123.4);
48 ASSERT ( (ret
== 5 && strcmp (buf
, " 123") == 0) /* AIX, Solaris */
49 || (ret
== 6 && strcmp (buf
, " 123") == 0) /* glibc */
50 || (ret
== 7 && strcmp (buf
, " 123 ") == 0) /* Mac OS X */
54 /* Test whether the decimal point comes from the right locale:
55 glibc bug <https://sourceware.org/bugzilla/show_bug.cgi?id=19633>. */
56 if (setlocale (LC_ALL
, "en_US.UTF-8") == NULL
)
58 fprintf (stderr
, "Skipping test: English Unicode locale is not installed\n");
61 if (setlocale (LC_ALL
, "de_DE.UTF-8") == NULL
)
63 fprintf (stderr
, "Skipping test: English Unicode locale is not installed\n");
67 char expected_buf
[80];
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);
80 char expected_buf
[80];
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);