summaryrefslogtreecommitdiff
path: root/test/testfmt.c
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-08-18 21:17:45 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2005-08-18 21:17:45 +0000
commited9829ff68d33442e1f835fbae13c18846fcf69f (patch)
treead71e0fad38cc74ce29701659f40fca6aa42b748 /test/testfmt.c
parent3672c3fea32f6ef79feef57f753a9a149a6203e3 (diff)
downloadlibapr-ed9829ff68d33442e1f835fbae13c18846fcf69f.tar.gz
* strings/apr_snprintf.c (apr_vformatter): Add support for %pm to
print the error string corresponding to an apr_status_t. * test/testfmt.c (error_fmt): New test. * include/apr_lib.h: Document %pm and note the versioning constraint. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@233381 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testfmt.c')
-rw-r--r--test/testfmt.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/testfmt.c b/test/testfmt.c
index 6cc2c3db4..f4548be36 100644
--- a/test/testfmt.c
+++ b/test/testfmt.c
@@ -117,6 +117,24 @@ static void more_int64_fmts(abts_case *tc, void *data)
ABTS_STR_EQUAL(tc, buf, "-314159265358979323");
}
+static void error_fmt(abts_case *tc, void *data)
+{
+ char ebuf[150], sbuf[150], *s;
+ apr_status_t rv;
+
+ rv = APR_SUCCESS;
+ apr_strerror(rv, ebuf, sizeof ebuf);
+ apr_snprintf(sbuf, sizeof sbuf, "%pm", &rv);
+ ABTS_STR_EQUAL(tc, sbuf, ebuf);
+
+ rv = APR_ENOTIMPL;
+ s = apr_pstrcat(p, "foo-",
+ apr_strerror(rv, ebuf, sizeof ebuf),
+ "-bar", NULL);
+ apr_snprintf(sbuf, sizeof sbuf, "foo-%pm-bar", &rv);
+ ABTS_STR_EQUAL(tc, sbuf, s);
+}
+
abts_suite *testfmt(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@@ -129,6 +147,7 @@ abts_suite *testfmt(abts_suite *suite)
abts_run_test(suite, uint64_t_fmt, NULL);
abts_run_test(suite, uint64_t_hex_fmt, NULL);
abts_run_test(suite, more_int64_fmts, NULL);
+ abts_run_test(suite, error_fmt, NULL);
return suite;
}