about summary refs log tree commit diff
path: root/localedata/tst-fmon.c
diff options
context:
space:
mode:
Diffstat (limited to 'localedata/tst-fmon.c')
-rw-r--r--localedata/tst-fmon.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/localedata/tst-fmon.c b/localedata/tst-fmon.c
new file mode 100644
index 0000000000..4b7146996e
--- /dev/null
+++ b/localedata/tst-fmon.c
@@ -0,0 +1,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;
+}