httpd-apreq-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: httpd-apreq-2/t params.c
Date Sun, 18 Jul 2004 05:27:27 GMT
randyk      2004/07/17 22:27:27

  Modified:    .        STATUS
               t        params.c
  Log:
  add memmem tests.
  
  Revision  Changes    Path
  1.74      +1 -2      httpd-apreq-2/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/STATUS,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- STATUS	18 Jul 2004 04:19:28 -0000	1.73
  +++ STATUS	18 Jul 2004 05:27:27 -0000	1.74
  @@ -61,7 +61,6 @@
       - The current tests don't cover these functions, 
         so add CuTest tests for them:
         -  apreq_merge_values()
  -      -  apreq_memmem()
   
       - CuTest needs va_arg to print comments for a failed unit test.
   
  
  
  
  1.18      +25 -1     httpd-apreq-2/t/params.c
  
  Index: params.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/t/params.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- params.c	18 Jul 2004 03:49:49 -0000	1.17
  +++ params.c	18 Jul 2004 05:27:27 -0000	1.18
  @@ -67,7 +67,7 @@
   {
       char *s1 = apr_palloc(p,4096);
       char *s2 = apr_palloc(p,4096);
  -    char *s3 = apr_palloc(p,4096);
  +    char *s3;
   
       strcpy(s1, "bend it like beckham");
       strcpy(s2, "dandy %3Edons");
  @@ -186,6 +186,29 @@
       }
   }
   
  +static void memmem(CuTest *tc)
  +{
  +    char *hay = apr_palloc(p,29);
  +    char *partial, *full;
  +    apr_size_t hlen = 28;
  +    strcpy(hay, "The fear of fear is fearful.");
  +
  +    partial = apreq_memmem(hay, hlen, "fear of fly", 11, APREQ_MATCH_PARTIAL);
  +    if (partial == NULL) CuAssertTrue(tc, 1);
  +    partial = apreq_memmem(hay, hlen, "fear ", 5, APREQ_MATCH_PARTIAL);
  +    CuAssertStrEquals(tc, "fear of fear is fearful.", partial);
  +    partial = apreq_memmem(hay, hlen, "fear is", 7, APREQ_MATCH_PARTIAL);
  +    CuAssertStrEquals(tc, "fear is fearful.", partial);
  +    partial = apreq_memmem(hay, hlen, hay, hlen, APREQ_MATCH_PARTIAL);
  +    CuAssertStrEquals(tc, hay, partial);
  +    full = apreq_memmem(hay, hlen, "fear is", 7, APREQ_MATCH_FULL);
  +    if (full == NULL) CuAssertTrue(tc, 1);
  +    partial = apreq_memmem(hay, hlen, "fear of fly", 11, APREQ_MATCH_FULL);
  +    if (partial == NULL) CuAssertTrue(tc, 1);
  +    full = apreq_memmem(hay, hlen, hay, hlen, APREQ_MATCH_FULL);
  +    CuAssertStrEquals(tc, hay, full);
  +}
  +
   CuSuite *testparam(void)
   {
       CuSuite *suite = CuSuiteNew("Param");
  @@ -198,6 +221,7 @@
       SUITE_ADD_TEST(suite, make_values);
       SUITE_ADD_TEST(suite, quote_strings);
       SUITE_ADD_TEST(suite, make_param);
  +    SUITE_ADD_TEST(suite, memmem);
   
       return suite;
   }
  
  
  

Mime
View raw message