apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject cvs commit: apr/test CuTest.h CuTest.c
Date Fri, 06 Dec 2002 11:44:01 GMT
jorton      2002/12/06 03:44:01

  Modified:    test     CuTest.h CuTest.c
  Log:
  Add CuAssertSuccess function for giving useful failure messages.
  (upstream formatting style maintained in CuTest.c, tabs and all)
  
  Revision  Changes    Path
  1.9       +7 -0      apr/test/CuTest.h
  
  Index: CuTest.h
  ===================================================================
  RCS file: /home/cvs/apr/test/CuTest.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CuTest.h	27 Nov 2002 05:28:38 -0000	1.8
  +++ CuTest.h	6 Dec 2002 11:44:01 -0000	1.9
  @@ -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 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 */
  
  
  
  1.12      +10 -0     apr/test/CuTest.c
  
  Index: CuTest.c
  ===================================================================
  RCS file: /home/cvs/apr/test/CuTest.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CuTest.c	27 Nov 2002 05:28:38 -0000	1.11
  +++ CuTest.c	6 Dec 2002 11:44:01 -0000	1.12
  @@ -216,6 +216,16 @@
   	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;
  
  
  

Mime
View raw message