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 Makefile.in test_apr.h testall.c testud.c
Date Tue, 22 Oct 2002 02:24:59 GMT
rbb         2002/10/21 19:24:59

  Modified:    test     Makefile.in test_apr.h testall.c testud.c
  Log:
  Port testud to the new test suite.
  
  Revision  Changes    Path
  1.94      +2 -2      apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.in,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- Makefile.in	13 Oct 2002 05:28:15 -0000	1.93
  +++ Makefile.in	22 Oct 2002 02:24:59 -0000	1.94
  @@ -209,8 +209,8 @@
   testtable@EXEEXT@: testtable.lo $(LOCAL_LIBS)
   	$(LINK) testtable.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
  -testall: testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo CuTest.lo
$(LOCAL_LIBS)
  -	$(LINK) testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo CuTest.lo
$(LOCAL_LIBS) $(ALL_LIBS)
  +testall: testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo
CuTest.lo $(LOCAL_LIBS)
  +	$(LINK) testall.lo testtime.lo teststr.lo testvsn.lo testipsub.lo testmmap.lo testud.lo
CuTest.lo $(LOCAL_LIBS) $(ALL_LIBS)
   
   
   # DO NOT REMOVE
  
  
  
  1.14      +1 -0      apr/test/test_apr.h
  
  Index: test_apr.h
  ===================================================================
  RCS file: /home/cvs/apr/test/test_apr.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- test_apr.h	13 Oct 2002 05:28:15 -0000	1.13
  +++ test_apr.h	22 Oct 2002 02:24:59 -0000	1.14
  @@ -71,6 +71,7 @@
   CuSuite *testvsn(void);
   CuSuite *testipsub(void);
   CuSuite *testmmap(void);
  +CuSuite *testud(void);
   
   
   
  
  
  
  1.6       +5 -3      apr/test/testall.c
  
  Index: testall.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testall.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- testall.c	13 Oct 2002 05:28:15 -0000	1.5
  +++ testall.c	22 Oct 2002 02:24:59 -0000	1.6
  @@ -57,7 +57,7 @@
   
   #include "test_apr.h"
   
  -#define NUM_TESTS 5
  +#define NUM_TESTS 255
   
   apr_pool_t *p;
   
  @@ -68,7 +68,9 @@
       testtime,
       testvsn,
       testipsub,
  -    testmmap
  +    testmmap,
  +    testud,
  +    NULL
   };
   
   int main(int argc, char *argv[])
  @@ -84,7 +86,7 @@
   
       apr_pool_create(&p, NULL);
   
  -    for (i = 0; i < NUM_TESTS; i++) {
  +    for (i = 0; tests[i]; i++) {
           CuSuiteListAdd(alltests, tests[i]());
       }
   
  
  
  
  1.5       +59 -17    apr/test/testud.c
  
  Index: testud.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testud.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- testud.c	13 Mar 2002 20:39:28 -0000	1.4
  +++ testud.c	22 Oct 2002 02:24:59 -0000	1.5
  @@ -61,36 +61,78 @@
   #include "apr_strings.h"
   #include "test_apr.h"
   
  +static apr_pool_t *pool;
  +static char *testdata;
  +static int cleanup_called = 0;
  +
   static apr_status_t string_cleanup(void *data)
   {
  +    cleanup_called = 1;
       return APR_SUCCESS;
   }
   
  -int main(void)
  +static void set_userdata(CuTest *tc)
  +{
  +    apr_status_t rv;
  +
  +    rv = apr_pool_userdata_set(testdata, "TEST", string_cleanup, pool);
  +    CuAssertIntEquals(tc, rv, APR_SUCCESS);
  +}
  +
  +static void get_userdata(CuTest *tc)
   {
  -    apr_pool_t *pool;
  -    char *testdata;
  +    apr_status_t rv;
       char *retdata;
   
  -    printf("APR User Data Test\n==================\n\n");
  +    rv = apr_pool_userdata_get((void **)&retdata, "TEST", pool);
  +    CuAssertIntEquals(tc, rv, APR_SUCCESS);
  +    CuAssertStrEquals(tc, retdata, testdata);
  +}
   
  -    STD_TEST_NEQ("Initializing APR", apr_initialize())
  -    atexit(apr_terminate);
  +static void get_nonexistkey(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    char *retdata;
   
  -    STD_TEST_NEQ("Creating a pool", apr_pool_create(&pool, NULL))
  +    rv = apr_pool_userdata_get((void **)&retdata, "DOESNTEXIST", pool);
  +    CuAssertTrue(tc, rv != APR_SUCCESS);
  +    CuAssertPtrEquals(tc, retdata, NULL);
  +    CuAssertIntEquals(tc, rv, APR_KEYNOTFOUND);
  +}
   
  +static void post_pool_clear(CuTest *tc)
  +{
  +    apr_status_t rv;
  +    char *retdata;
  +
  +    rv = apr_pool_userdata_get((void **)&retdata, "DOESNTEXIST", pool);
  +    CuAssertTrue(tc, rv != APR_SUCCESS);
  +    CuAssertPtrEquals(tc, retdata, NULL);
  +    CuAssertIntEquals(tc, rv, APR_KEYNOTFOUND);
  +}
  +
  +CuSuite *testud(void)
  +{
  +    CuSuite *suite = CuSuiteNew("Test User Data");
  +
  +    apr_pool_create(&pool, p);
       testdata = apr_pstrdup(pool, "This is a test\n");
   
  -    printf("Testing pool\n");
  -    STD_TEST_NEQ("    Setting user data into the pool",
  -          apr_pool_userdata_set(testdata, "TEST", string_cleanup, pool))
  -    
  -    STD_TEST_NEQ("    Getting user data from the pool",
  -          apr_pool_userdata_get((void **)&retdata, "TEST", pool))
  +    SUITE_ADD_TEST(suite, set_userdata);
  +    SUITE_ADD_TEST(suite, get_userdata);
  +    SUITE_ADD_TEST(suite, get_nonexistkey);
   
  -    TEST_NEQ("    Checking the data we got", strcmp(testdata, retdata),
  -             0, "OK","Failed :(")
  +    apr_pool_clear(pool);
   
  -    printf("\nTest complete\n");
  -    return 0;
  +    SUITE_ADD_TEST(suite, post_pool_clear);
  +
  +    return suite;
   }
  +
  +#ifdef SINGLE_PROG
  +CuSuite *getsuite(void)
  +{
  +    return testud();
  +}
  +#endif
  +
  
  
  

Mime
View raw message