summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2002-12-06 11:44:01 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2002-12-06 11:44:01 +0000
commit3a39d3cc7b9a98c636e49ae6bbfcda975aa709b1 (patch)
tree3927fbd2d886b3dce6e0ec6146a2c36656704447
parentee377e0f724f3d4b52625ed8c62d3465dd0fa66c (diff)
downloadlibapr-3a39d3cc7b9a98c636e49ae6bbfcda975aa709b1.tar.gz
Add CuAssertSuccess function for giving useful failure messages.
(upstream formatting style maintained in CuTest.c, tabs and all) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64121 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--test/CuTest.c10
-rw-r--r--test/CuTest.h7
2 files changed, 17 insertions, 0 deletions
diff --git a/test/CuTest.c b/test/CuTest.c
index 6b15bcef1..9e1b3792a 100644
--- a/test/CuTest.c
+++ b/test/CuTest.c
@@ -216,6 +216,16 @@ void CuAssertPtrNotNull(CuTest* tc, const void* pointer)
CuFail(tc, buf);
}
+void CuAssertSuccess(CuTest* tc, const char* context, apr_status_t rv)
+{
+ if (!APR_STATUS_IS_SUCCESS(rv)) {
+ char buf[STRING_MAX], ebuf[128];
+ sprintf(buf, "%s (%d): %s\n", context, rv,
+ apr_strerror(rv, ebuf, sizeof ebuf));
+ CuFail(tc, buf);
+ }
+}
+
void CuTestRun(CuTest* tc)
{
jmp_buf buf;
diff --git a/test/CuTest.h b/test/CuTest.h
index 8d93818bc..3ff882c9b 100644
--- a/test/CuTest.h
+++ b/test/CuTest.h
@@ -32,6 +32,8 @@
#ifndef CU_TEST_H
#define CU_TEST_H
+#include "apr_errno.h" /* for apr_status_t */
+
#include <setjmp.h>
#include <stdarg.h>
@@ -89,6 +91,11 @@ void CuAssertStrEquals(CuTest* tc, const char* expected, const char* actual);
void CuAssertIntEquals(CuTest* tc, int expected, int actual);
void CuAssertPtrEquals(CuTest* tc, const void* expected, const void* actual);
void CuAssertPtrNotNull(CuTest* tc, const void* pointer);
+
+/* Assert that RV is an APR_SUCCESS value; else fail giving strerror
+ * for RV and CONTEXT message. */
+void CuAssertSuccess(CuTest* tc, const char *context, apr_status_t rv);
+
void CuTestRun(CuTest* tc);
/* CuSuite */