Back to index

glibc  2.9
bug16.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <string.h>
00003 
00004 struct
00005 {
00006   long double val;
00007   const char str[4][7];
00008 } tests[] =
00009 {
00010   { 0x0.FFFFp+0L, { "0X1P+0", "0X2P-1", "0X4P-2", "0X8P-3" } },
00011   { 0x0.FFFFp+1L, { "0X1P+1", "0X2P+0", "0X4P-1", "0X8P-2" } },
00012   { 0x0.FFFFp+2L, { "0X1P+2", "0X2P+1", "0X4P+0", "0X8P-1" } },
00013   { 0x0.FFFFp+3L, { "0X1P+3", "0X2P+2", "0X4P+1", "0X8P+0" } }
00014 };
00015 
00016 static int
00017 do_test (void)
00018 {
00019   char buf[100];
00020   int ret = 0;
00021 
00022   for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
00023     {  
00024       snprintf (buf, sizeof (buf), "%.0LA", tests[i].val);
00025 
00026       size_t j;
00027       for (j = 0; j < 4; ++j)
00028        if (strcmp (buf, tests[i].str[j]) == 0)
00029          break;
00030 
00031       if (j == 4)
00032        {
00033          printf ("%zd: got \"%s\", expected \"%s\" or equivalent\n",
00034                 i, buf, tests[i].str[0]);
00035          ret = 1;
00036        }
00037     }
00038 
00039   return ret;
00040 }
00041 
00042 #define TEST_FUNCTION do_test ()
00043 #include "../test-skeleton.c"