Mercurial > hg > octave-lojdl > gnulib-hg
changeset 12273:0c24082ae7d9
test-xvasprintf: Add %s%s related checks.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Fri, 13 Nov 2009 10:53:06 +0100 |
parents | 1660263d2a54 |
children | 88fe10a9db6a |
files | ChangeLog tests/test-xvasprintf.c |
diffstat | 2 files changed, 40 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-11-13 Simon Josefsson <simon@josefsson.org> + + * tests/test-xvasprintf.c: Add %s%s related checks. + 2009-11-12 Eric Blake <ebb9@byu.net> version-etc: match standards.texi style
--- a/tests/test-xvasprintf.c +++ b/tests/test-xvasprintf.c @@ -55,28 +55,62 @@ test_xvasprintf (void) { int repeat; + char *result; for (repeat = 0; repeat <= 8; repeat++) { - char *result = my_xasprintf ("%d", 12345); + result = my_xasprintf ("%d", 12345); ASSERT (result != NULL); ASSERT (strcmp (result, "12345") == 0); free (result); } + + result = my_xasprintf (""); + ASSERT (result != NULL); + ASSERT (strcmp (result, "") == 0); + + result = my_xasprintf ("%s", "foo"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foo") == 0); + + result = my_xasprintf ("%s%s", "foo", "bar"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foobar") == 0); + + result = my_xasprintf ("%s%sbaz", "foo", "bar"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foobarbaz") == 0); } static void test_xasprintf () { int repeat; + char *result; for (repeat = 0; repeat <= 8; repeat++) { - char *result = xasprintf ("%d", 12345); + result = xasprintf ("%d", 12345); ASSERT (result != NULL); ASSERT (strcmp (result, "12345") == 0); free (result); } + + result = xasprintf (""); + ASSERT (result != NULL); + ASSERT (strcmp (result, "") == 0); + + result = xasprintf ("%s", "foo"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foo") == 0); + + result = xasprintf ("%s%s", "foo", "bar"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foobar") == 0); + + result = my_xasprintf ("%s%sbaz", "foo", "bar"); + ASSERT (result != NULL); + ASSERT (strcmp (result, "foobarbaz") == 0); } int