[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
improved xvasprintf self test
From: |
Simon Josefsson |
Subject: |
improved xvasprintf self test |
Date: |
Fri, 13 Nov 2009 10:53:34 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) |
Inspired by
http://www.gnu.org/software/gnulib/coverage/gllib/xvasprintf.c.gcov.frameset.html
I improved the xvasprintf self-check below.
/Simon
>From e718463703e9f7a3d60eeb360fca7efb2562c6b2 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
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 405bfda..34915a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-11-13 Simon Josefsson <address@hidden>
+
+ * tests/test-xvasprintf.c: Add %s%s related checks.
+
2009-11-12 Eric Blake <address@hidden>
version-etc: match standards.texi style
diff --git a/tests/test-xvasprintf.c b/tests/test-xvasprintf.c
index 3760314..5296b67 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
--
1.6.5.2
- improved xvasprintf self test,
Simon Josefsson <=