apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: apr/test CuTest.c CuTest.h teststr.c
Date Thu, 19 Dec 2002 01:49:18 GMT
rbb         2002/12/18 17:49:18

  Modified:    test     CuTest.c CuTest.h teststr.c
  Log:
  Add a CuAssertStrnEquals which does a strncmp instead of a strcmp.  This
  fixes a big in teststr.
  
  Revision  Changes    Path
  1.16      +14 -0     apr/test/CuTest.c
  
  Index: CuTest.c
  ===================================================================
  RCS file: /home/cvs/apr/test/CuTest.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CuTest.c	11 Dec 2002 20:54:35 -0000	1.15
  +++ CuTest.c	19 Dec 2002 01:49:17 -0000	1.16
  @@ -182,6 +182,20 @@
   	CuFail(tc, "assert failed");
   }
   
  +void CuAssertStrNEquals(CuTest* tc, const char* expected, const char* actual,
  +                        int n)
  +{
  +	CuString* message;
  +	if (strncmp(expected, actual, n) == 0) return;
  +	message = CuStringNew();
  +	CuStringAppend(message, "expected\n---->\n");
  +	CuStringAppend(message, expected);
  +	CuStringAppend(message, "\n<----\nbut saw\n---->\n");
  +	CuStringAppend(message, actual);
  +	CuStringAppend(message, "\n<----\n");
  +	CuFail(tc, message->buffer);
  +}
  +
   void CuAssertStrEquals(CuTest* tc, const char* expected, const char* actual)
   {
   	CuString* message;
  
  
  
  1.12      +2 -0      apr/test/CuTest.h
  
  Index: CuTest.h
  ===================================================================
  RCS file: /home/cvs/apr/test/CuTest.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CuTest.h	11 Dec 2002 18:21:40 -0000	1.11
  +++ CuTest.h	19 Dec 2002 01:49:18 -0000	1.12
  @@ -86,6 +86,8 @@
   void CuAssert(CuTest* tc, const char* message, int condition);
   void CuAssertTrue(CuTest* tc, int condition);
   void CuAssertStrEquals(CuTest* tc, const char* expected, const char* actual);
  +void CuAssertStrNEquals(CuTest* tc, const char* expected, const char* actual,
  +                        int n);
   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);
  
  
  
  1.12      +1 -1      apr/test/teststr.c
  
  Index: teststr.c
  ===================================================================
  RCS file: /home/cvs/apr/test/teststr.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- teststr.c	24 Nov 2002 04:57:35 -0000	1.11
  +++ teststr.c	19 Dec 2002 01:49:18 -0000	1.12
  @@ -142,7 +142,7 @@
       
       /* If this test fails, we are going to seg fault. */
       apr_snprintf(buff, sizeof(buff), "%.*s", 7, testing);
  -    CuAssertStrEquals(tc, buff, testing);
  +    CuAssertStrNEquals(tc, buff, testing, 7);
   }
   
   static void snprintf_0NULL(CuTest *tc)
  
  
  

Mime
View raw message