summaryrefslogtreecommitdiff
path: root/tests/test-vasnprintf-posix.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-02-07 02:08:13 +0100
committerBruno Haible <bruno@clisp.org>2008-02-07 02:08:13 +0100
commit6cad9c91215eac0f90bbb1f9473ea0f5fce3b085 (patch)
treeeb9e9529c870497dc2fa4638740a1f6a09b7c6c3 /tests/test-vasnprintf-posix.c
parente2cc522f19bb9144ad1ee284152bd2b0a1c43427 (diff)
downloadgnulib-6cad9c91215eac0f90bbb1f9473ea0f5fce3b085.tar.gz
Fix *printf behaviour regarding the left-adjust flag on HP-UX 10.20.
Diffstat (limited to 'tests/test-vasnprintf-posix.c')
-rw-r--r--tests/test-vasnprintf-posix.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/test-vasnprintf-posix.c b/tests/test-vasnprintf-posix.c
index 8ee6301993..e947cc79fb 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 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008 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
@@ -3253,6 +3253,38 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
free (result);
}
+ /* Test the support of the left-adjust flag. */
+
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "a%*sc", -3, "b");
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "ab c") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "a%-*sc", 3, "b");
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "ab c") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "a%-*sc", -3, "b");
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "ab c") == 0);
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
/* Test the support of large precision. */
{