X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-vasnprintf-posix.c;h=dea0d3c1b29b8cd142155c680104bc68cee3f9ce;hb=5d8fde12eeff4659e84a839851125b98eb477200;hp=66b4eb4265303dcc72508977a92893366b875f6a;hpb=74f73e82d45826c2ba8e533ff3ec75fcf9e17361;p=gnulib.git diff --git a/tests/test-vasnprintf-posix.c b/tests/test-vasnprintf-posix.c index 66b4eb426..dea0d3c1b 100644 --- a/tests/test-vasnprintf-posix.c +++ b/tests/test-vasnprintf-posix.c @@ -1,5 +1,5 @@ /* Test of POSIX compatible vasnprintf() and asnprintf() functions. - Copyright (C) 2007-2010 Free Software Foundation, Inc. + Copyright (C) 2007-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3553,6 +3553,36 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) } { + size_t length; + char *result = + my_asnprintf (NULL, &length, "%.4000f %d", 1.0, 99); + size_t i; + ASSERT (result != NULL); + ASSERT (result[0] == '1'); + ASSERT (result[1] == '.'); + for (i = 0; i < 4000; i++) + ASSERT (result[2 + i] == '0'); + ASSERT (strcmp (result + 2 + 4000, " 99") == 0); + ASSERT (length == strlen (result)); + free (result); + } + + { + size_t length; + char *result = + my_asnprintf (NULL, &length, "%.511f %d", 1.0, 99); + size_t i; + ASSERT (result != NULL); + ASSERT (result[0] == '1'); + ASSERT (result[1] == '.'); + for (i = 0; i < 511; i++) + ASSERT (result[2 + i] == '0'); + ASSERT (strcmp (result + 2 + 511, " 99") == 0); + ASSERT (length == strlen (result)); + free (result); + } + + { char input[5000]; size_t length; char *result; @@ -3658,6 +3688,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...)) free (result); } #endif + +#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) && !defined __UCLIBC__ + /* Test that the 'I' flag is supported. */ + { + size_t length; + char *result = + my_asnprintf (NULL, &length, "%Id %d", 1234567, 99); + ASSERT (result != NULL); + ASSERT (strcmp (result, "1234567 99") == 0); + ASSERT (length == strlen (result)); + free (result); + } +#endif } static char *