X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-snprintf-posix.h;h=c0c95939040731120b47734e515c75586c52ff39;hb=c3631123354a030261b19e206205bbfb973af38b;hp=f55e49e4767fe5772538b762e52e360e06afe9dd;hpb=74f73e82d45826c2ba8e533ff3ec75fcf9e17361;p=gnulib.git diff --git a/tests/test-snprintf-posix.h b/tests/test-snprintf-posix.h index f55e49e47..c0c959390 100644 --- a/tests/test-snprintf-posix.h +++ b/tests/test-snprintf-posix.h @@ -1,5 +1,5 @@ /* Test of POSIX compatible vsnprintf() and snprintf() 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 @@ -3032,6 +3032,32 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...)) } { + char result[5000]; + int retval = + my_snprintf (result, sizeof (result), "%.4000f %d", 1.0, 99); + size_t i; + 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 (retval == strlen (result)); + } + + { + char result[1000]; + int retval = + my_snprintf (result, sizeof (result), "%.511f %d", 1.0, 99); + size_t i; + 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 (retval == strlen (result)); + } + + { char input[5000]; char result[5000]; int retval;