about summary refs log tree commit diff
path: root/stdio-common/bug16.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /stdio-common/bug16.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.xz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
2.5-18.1
Diffstat (limited to 'stdio-common/bug16.c')
-rw-r--r--stdio-common/bug16.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/stdio-common/bug16.c b/stdio-common/bug16.c
new file mode 100644
index 0000000000..84269f3b6d
--- /dev/null
+++ b/stdio-common/bug16.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <string.h>
+
+struct
+{
+  long double val;
+  const char str[4][7];
+} tests[] =
+{
+  { 0x0.FFFFp+0L, { "0X1P+0", "0X2P-1", "0X4P-2", "0X8P-3" } },
+  { 0x0.FFFFp+1L, { "0X1P+1", "0X2P+0", "0X4P-1", "0X8P-2" } },
+  { 0x0.FFFFp+2L, { "0X1P+2", "0X2P+1", "0X4P+0", "0X8P-1" } },
+  { 0x0.FFFFp+3L, { "0X1P+3", "0X2P+2", "0X4P+1", "0X8P+0" } }
+};
+
+static int
+do_test (void)
+{
+  char buf[100];
+  int ret = 0;
+
+  for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+    {  
+      snprintf (buf, sizeof (buf), "%.0LA", tests[i].val);
+
+      size_t j;
+      for (j = 0; j < 4; ++j)
+	if (strcmp (buf, tests[i].str[j]) == 0)
+	  break;
+
+      if (j == 4)
+	{
+	  printf ("%zd: got \"%s\", expected \"%s\" or equivalent\n",
+		  i, buf, tests[i].str[0]);
+	  ret = 1;
+	}
+    }
+
+  return ret;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"