about summary refs log tree commit diff
path: root/libio/tst_swprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libio/tst_swprintf.c')
-rw-r--r--libio/tst_swprintf.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libio/tst_swprintf.c b/libio/tst_swprintf.c
new file mode 100644
index 0000000000..67d10a006d
--- /dev/null
+++ b/libio/tst_swprintf.c
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <wchar.h>
+
+int
+main (int argc, char *argv[])
+{
+  wchar_t buf[100];
+  int n;
+  int result = 0;
+
+  puts ("test 1");
+  n = swprintf (buf, sizeof (buf) / sizeof (buf[0]), L"Hello %s", "world");
+  if (n != 11)
+    {
+      printf ("incorrect return value: %d instead of 11\n", n);
+      result = 1;
+    }
+
+  if (wcscmp (buf, L"Hello world") != 0)
+    {
+      printf ("incorrect string: L\"%ls\" instead of L\"Hello world\"\n", buf);
+      result = 1;
+    }
+
+  puts ("test 2");
+  n = swprintf (buf, sizeof (buf) / sizeof (buf[0]), L"Is this >%g< 3.1?",
+		3.1);
+  if (n != 18)
+{
+      printf ("incorrect return value: %d instead of 18\n", n);
+      result = 1;
+    }
+
+  if (wcscmp (buf, L"Is this >3.1< 3.1?") != 0)
+    {
+      printf ("incorrect string: L\"%ls\" instead of L\"Is this >3.1< 3.1?\"\n",
+	      buf);
+      result = 1;
+    }
+
+  return result;
+}