apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1357761 - in /apr/apr/trunk/test: testutil.c testutil.h
Date Thu, 05 Jul 2012 17:41:44 GMT
Author: sf
Date: Thu Jul  5 17:41:44 2012
New Revision: 1357761

URL: http://svn.apache.org/viewvc?rev=1357761&view=rev
Log:
Add an APR_ASSERT_FAILURE macro for tests that must fail

Modified:
    apr/apr/trunk/test/testutil.c
    apr/apr/trunk/test/testutil.h

Modified: apr/apr/trunk/test/testutil.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testutil.c?rev=1357761&r1=1357760&r2=1357761&view=diff
==============================================================================
--- apr/apr/trunk/test/testutil.c (original)
+++ apr/apr/trunk/test/testutil.c Thu Jul  5 17:41:44 2012
@@ -36,6 +36,18 @@ void apr_assert_success(abts_case* tc, c
     }
 }
 
+void apr_assert_failure(abts_case* tc, const char* context, apr_status_t rv,
+                        int lineno)
+{
+    if (rv == APR_ENOTIMPL) {
+        abts_not_impl(tc, context, lineno);
+    } else if (rv == APR_SUCCESS) {
+        char buf[STRING_MAX];
+        sprintf(buf, "%s (%d): expected failure, got success\n", context, rv);
+        abts_fail(tc, buf, lineno);
+    }
+}
+
 void initialize(void) {
     apr_initialize();
     atexit(apr_terminate);

Modified: apr/apr/trunk/test/testutil.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testutil.h?rev=1357761&r1=1357760&r2=1357761&view=diff
==============================================================================
--- apr/apr/trunk/test/testutil.h (original)
+++ apr/apr/trunk/test/testutil.h Thu Jul  5 17:41:44 2012
@@ -58,6 +58,12 @@ void apr_assert_success(abts_case* tc, c
 #define APR_ASSERT_SUCCESS(tc, ctxt, rv) \
              apr_assert_success(tc, ctxt, rv, __LINE__)
 
+void apr_assert_failure(abts_case* tc, const char *context,
+                        apr_status_t rv, int lineno);
+#define APR_ASSERT_FAILURE(tc, ctxt, rv) \
+             apr_assert_failure(tc, ctxt, rv, __LINE__)
+
+
 void initialize(void);
 
 abts_suite *testatomic(abts_suite *suite);



Mime
View raw message