X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-vasprintf-posix.c;h=5b4389127c6ebee0760937411be35c10d86a4eb9;hb=b0d9d3aa695aebab5ebc0fb02ebeac9e59f57242;hp=af6ed7165c211c32493ac5b631d6b649860364aa;hpb=c284d39d902ca78da360066b103e48d7476c409d;p=gnulib.git diff --git a/tests/test-vasprintf-posix.c b/tests/test-vasprintf-posix.c index af6ed7165..5b4389127 100644 --- a/tests/test-vasprintf-posix.c +++ b/tests/test-vasprintf-posix.c @@ -34,7 +34,6 @@ static void test_function (int (*my_asprintf) (char **, const char *, ...)) { - char buf[8]; int repeat; /* Test return value convention. */ @@ -250,6 +249,20 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) free (result); } + { /* Rounding can turn a ...FFF into a ...000. + This shows a MacOS X 10.3.9 (Darwin 7.9) bug. */ + char *result; + int retval = + my_asprintf (&result, "%.1a %d", 1.999, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.0p+1 33") == 0 + || strcmp (result, "0x2.0p+0 33") == 0 + || strcmp (result, "0x4.0p-1 33") == 0 + || strcmp (result, "0x8.0p-2 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + { /* Width. */ char *result; int retval = @@ -543,6 +556,21 @@ test_function (int (*my_asprintf) (char **, const char *, ...)) free (result); } + { /* Rounding can turn a ...FFF into a ...000. + This shows a MacOS X 10.3.9 (Darwin 7.9) bug and a + glibc 2.4 bug . */ + char *result; + int retval = + my_asprintf (&result, "%.1La %d", 1.999L, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0x1.0p+1 33") == 0 + || strcmp (result, "0x2.0p+0 33") == 0 + || strcmp (result, "0x4.0p-1 33") == 0 + || strcmp (result, "0x8.0p-2 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } + { /* Width. */ char *result; int retval =