aboutsummaryrefslogtreecommitdiff
path: root/tests/portable/asprintf-t.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/portable/asprintf-t.c')
-rw-r--r--tests/portable/asprintf-t.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/tests/portable/asprintf-t.c b/tests/portable/asprintf-t.c
index d42e740..04fbd1b 100644
--- a/tests/portable/asprintf-t.c
+++ b/tests/portable/asprintf-t.c
@@ -1,9 +1,9 @@
-/* $Id$
- *
+/*
* asprintf and vasprintf test suite.
*
* Written by Russ Allbery <rra@stanford.edu>
- * Copyright 2006, 2008 Board of Trustees, Leland Stanford Jr. University
+ * Copyright 2006, 2008, 2009
+ * Board of Trustees, Leland Stanford Jr. University
*
* See LICENSE for licensing terms.
*/
@@ -11,9 +11,10 @@
#include <config.h>
#include <portable/system.h>
-#include <tests/libtest.h>
+#include <tests/tap/basic.h>
-int test_asprintf(char **, const char *, ...);
+int test_asprintf(char **, const char *, ...)
+ __attribute__((__format__(printf, 2, 3)));
int test_vasprintf(char **, const char *, va_list);
static int
@@ -33,25 +34,25 @@ main(void)
{
char *result = NULL;
- test_init(12);
+ plan(12);
- ok_int(1, 7, test_asprintf(&result, "%s", "testing"));
- ok_string(2, "testing", result);
+ is_int(7, test_asprintf(&result, "%s", "testing"), "asprintf length");
+ is_string("testing", result, "asprintf result");
free(result);
- ok(3, 1);
- ok_int(4, 0, test_asprintf(&result, "%s", ""));
- ok_string(5, "", result);
+ ok(3, "free asprintf");
+ is_int(0, test_asprintf(&result, "%s", ""), "asprintf empty length");
+ is_string("", result, "asprintf empty string");
free(result);
- ok(6, 1);
+ ok(6, "free asprintf of empty string");
- ok_int(7, 6, vatest(&result, "%d %s", 2, "test"));
- ok_string(8, "2 test", result);
+ is_int(6, vatest(&result, "%d %s", 2, "test"), "vasprintf length");
+ is_string("2 test", result, "vasprintf result");
free(result);
- ok(9, 1);
- ok_int(10, 0, vatest(&result, "%s", ""));
- ok_string(11, "", result);
+ ok(9, "free vasprintf");
+ is_int(0, vatest(&result, "%s", ""), "vasprintf empty length");
+ is_string("", result, "vasprintf empty string");
free(result);
- ok(12, 1);
+ ok(12, "free vasprintf of empty string");
return 0;
}