From e718463703e9f7a3d60eeb360fca7efb2562c6b2 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Fri, 13 Nov 2009 10:53:06 +0100 Subject: [PATCH] test-xvasprintf: Add %s%s related checks. --- ChangeLog | 4 ++++ tests/test-xvasprintf.c | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 405bfdaa53..34915a0478 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-11-13 Simon Josefsson + + * tests/test-xvasprintf.c: Add %s%s related checks. + 2009-11-12 Eric Blake version-etc: match standards.texi style diff --git a/tests/test-xvasprintf.c b/tests/test-xvasprintf.c index 37603142f9..5296b67a34 100644 --- a/tests/test-xvasprintf.c +++ b/tests/test-xvasprintf.c @@ -55,28 +55,62 @@ static void 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 -- 2.30.2