apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr-util/test Makefile.in abts_tests.h teststrmatch.c testutil.h
Date Tue, 22 Jun 2004 10:24:52 GMT
dreid       2004/06/22 03:24:51

  Modified:    test     Makefile.in abts_tests.h teststrmatch.c testutil.h
  Log:
  Move the strmatch test to use abts.
  
  Revision  Changes    Path
  1.43      +2 -7      apr-util/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr-util/test/Makefile.in,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Makefile.in	21 Jun 2004 15:19:10 -0000	1.42
  +++ Makefile.in	22 Jun 2004 10:24:51 -0000	1.43
  @@ -3,7 +3,7 @@
   INCLUDES = @APRUTIL_PRIV_INCLUDES@ @APR_INCLUDES@ @APRUTIL_INCLUDES@
   
   PROGRAMS = testall testdbm testdate testmd4 testmd5 testxml testrmm \
  -	teststrmatch testreslist testqueue testpass
  +	   testreslist testqueue testpass
   TARGETS = $(PROGRAMS)
   
   APRUTIL_DOTTED_VERSION=@APRUTIL_DOTTED_VERSION@
  @@ -56,11 +56,6 @@
   testrmm: $(testrmm_OBJECTS) $(testrmm_LDADD)
   	$(LINK) $(APRUTIL_LDFLAGS) $(testrmm_OBJECTS) $(testrmm_LDADD) $(PROGRAM_DEPENDENCIES)
   
  -teststrmatch_OBJECTS = teststrmatch.lo
  -teststrmatch_LDADD =  $(TARGET_LIB_PATH)
  -teststrmatch: $(teststrmatch_OBJECTS) $(teststrmatch_LDADD)
  -	$(LINK) $(APRUTIL_LDFLAGS) $(teststrmatch_OBJECTS) $(teststrmatch_LDADD) $(PROGRAM_DEPENDENCIES)
  -
   testreslist_OBJECTS = testreslist.lo
   testreslist_LDADD =  $(TARGET_LIB_PATH)
   testreslist: $(testreslist_OBJECTS) $(testreslist_LDADD)
  @@ -76,7 +71,7 @@
   testpass: $(testpass_OBJECTS) $(testpass_LDADD)
   	$(LINK) $(APRUTIL_LDFLAGS) $(testpass_OBJECTS) $(testpass_LDADD) $(PROGRAM_DEPENDENCIES)
   
  -testall_OBJECTS = testuri.lo testuuid.lo abts.lo testutil.lo
  +testall_OBJECTS = teststrmatch.lo testuri.lo testuuid.lo abts.lo testutil.lo
   testall_LDADD =  $(TARGET_LIB_PATH)
   testall: $(testall_OBJECTS) $(testall_LDADD)
   	$(LINK) $(APRUTIL_LDFLAGS) $(testall_OBJECTS) $(testall_LDADD) $(PROGRAM_DEPENDENCIES)
  
  
  
  1.3       +1 -0      apr-util/test/abts_tests.h
  
  Index: abts_tests.h
  ===================================================================
  RCS file: /home/cvs/apr-util/test/abts_tests.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- abts_tests.h	21 Jun 2004 15:19:10 -0000	1.2
  +++ abts_tests.h	22 Jun 2004 10:24:51 -0000	1.3
  @@ -22,6 +22,7 @@
   const struct testlist {
       abts_suite *(*func)(abts_suite *suite);
   } alltests[] = {
  +    (teststrmatch),
       (testuri),
       {testuuid}
   };
  
  
  
  1.7       +54 -88    apr-util/test/teststrmatch.c
  
  Index: teststrmatch.c
  ===================================================================
  RCS file: /home/cvs/apr-util/test/teststrmatch.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- teststrmatch.c	13 Feb 2004 09:55:26 -0000	1.6
  +++ teststrmatch.c	22 Jun 2004 10:24:51 -0000	1.7
  @@ -13,6 +13,8 @@
    * limitations under the License.
    */
   
  +#include "testutil.h"
  +
   #include "apr.h"
   #include "apr_general.h"
   #include "apr_strmatch.h"
  @@ -23,14 +25,14 @@
   #define APR_WANT_STRFUNC
   #include "apr_want.h"
   
  -
  -int main (void)
  +static void test_str(abts_case *tc, void *data)
   {
  -    apr_pool_t *pool;
  +    apr_pool_t *pool = (apr_pool_t *)data;
       const apr_strmatch_pattern *pattern;
       const apr_strmatch_pattern *pattern_nocase;
       const apr_strmatch_pattern *pattern_onechar;
       const apr_strmatch_pattern *pattern_zero;
  +    const char *match = NULL;
       const char *input1 = "string that contains a patterN...";
       const char *input2 = "string that contains a pattern...";
       const char *input3 = "pattern at the start of a string";
  @@ -38,94 +40,58 @@
       const char *input5 = "patter\200n not found, negative chars in input";
       const char *input6 = "patter\200n, negative chars, contains pattern...";
   
  -    (void) apr_initialize();
  -    apr_pool_create(&pool, NULL);
  -
  -    printf("testing pattern precompilation...");
       pattern = apr_strmatch_precompile(pool, "pattern", 1);
  -    if (!pattern) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  +    ABTS_PTR_NOTNULL(tc, pattern);
  + 
       pattern_nocase = apr_strmatch_precompile(pool, "pattern", 0);
  -    if (!pattern_nocase) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  +    ABTS_PTR_NOTNULL(tc, pattern_nocase);
  +
       pattern_onechar = apr_strmatch_precompile(pool, "g", 0);
  -    if (!pattern_onechar) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  +    ABTS_PTR_NOTNULL(tc, pattern_onechar);
  +
       pattern_zero = apr_strmatch_precompile(pool, "", 0);
  -    if (!pattern_zero) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing invalid match...");
  -    if (apr_strmatch(pattern, input1, strlen(input1)) != NULL) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing valid match...");
  -    if (apr_strmatch(pattern, input2, strlen(input2)) != input2 + 23) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing single-character match...");
  -    if (apr_strmatch(pattern_onechar, input1, strlen(input1)) != input1 + 5) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing zero-length pattern...");
  -    if (apr_strmatch(pattern_zero, input1, strlen(input1)) != input1) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing inexact-case match...");
  -    if (apr_strmatch(pattern_nocase, input1, strlen(input1)) != input1 + 23) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing match at start of string...");
  -    if (apr_strmatch(pattern, input3, strlen(input3)) != input3) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing match at end of string...");
  -    if (apr_strmatch(pattern, input4, strlen(input4)) != input4 + 24) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing invalid match with negative chars in input string...");
  -    if (apr_strmatch(pattern, input5, strlen(input5)) != NULL) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  -
  -    printf("testing valid match with negative chars in input string...");
  -    if (apr_strmatch(pattern, input6, strlen(input6)) != input6 + 35) {
  -        printf("FAILED\n");
  -        exit(1);
  -    }
  -    printf("OK\n");
  +    ABTS_PTR_NOTNULL(tc, pattern_zero);
  +
  +    match = apr_strmatch(pattern, input1, strlen(input1));
  +    ABTS_PTR_EQUAL(tc, match, NULL);
  +
  +    match = apr_strmatch(pattern, input2, strlen(input2));
  +    ABTS_PTR_EQUAL(tc, match, input2 + 23);
  +
  +    match = apr_strmatch(pattern_onechar, input1, strlen(input1));
  +    ABTS_PTR_EQUAL(tc, match, input1 + 5);
  +
  +    match = apr_strmatch(pattern_zero, input1, strlen(input1));
  +    ABTS_PTR_EQUAL(tc, match, input1);
  +
  +    match = apr_strmatch(pattern_nocase, input1, strlen(input1));
  +    ABTS_PTR_EQUAL(tc, match, input1 + 23);
  +
  +    match = apr_strmatch(pattern, input3, strlen(input3));
  +    ABTS_PTR_EQUAL(tc, match, input3);
   
  -    exit(0);
  +    match = apr_strmatch(pattern, input4, strlen(input4));
  +    ABTS_PTR_EQUAL(tc, match, input4 + 24);
  +
  +    match = apr_strmatch(pattern, input5, strlen(input5));
  +    ABTS_PTR_EQUAL(tc, match, NULL);
  +
  +    match = apr_strmatch(pattern, input6, strlen(input6));
  +    ABTS_PTR_EQUAL(tc, match, input6 + 35);
   }
  +
  +abts_suite *teststrmatch(abts_suite *suite)
  +{
  +    apr_pool_t *pool;
  +
  +    suite = ADD_SUITE(suite);
  +
  +    apr_pool_create(&pool, NULL);
  +
  +    abts_run_test(suite, test_str, pool);
  +
  +    apr_pool_destroy(pool);
  +
  +    return suite;
  +}
  +
  
  
  
  1.3       +1 -0      apr-util/test/testutil.h
  
  Index: testutil.h
  ===================================================================
  RCS file: /home/cvs/apr-util/test/testutil.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- testutil.h	21 Jun 2004 15:19:10 -0000	1.2
  +++ testutil.h	22 Jun 2004 10:24:51 -0000	1.3
  @@ -42,6 +42,7 @@
   
   void initialize(void);
   
  +abts_suite *teststrmatch(abts_suite *);
   abts_suite *testuri(abts_suite *);
   abts_suite *testuuid(abts_suite *suite);
   
  
  
  

Mime
View raw message