NEWS.stable: log cherry-pick [24bfc89]->[1d71dc7] strtoumax: Avoid link error on...
[gnulib.git] / tests / test-vasprintf-posix.c
index cd48493..b819b5b 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of POSIX compatible vasprintf() and asprintf() 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
@@ -3533,6 +3533,36 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   }
 
   {
+    char *result;
+    int retval =
+      my_asprintf (&result, "%.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 (retval == strlen (result));
+    free (result);
+  }
+
+  {
+    char *result;
+    int retval =
+      my_asprintf (&result, "%.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 (retval == strlen (result));
+    free (result);
+  }
+
+  {
     char input[5000];
     char *result;
     int retval;