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 03:09:57 GMT
randyk      2004/07/17 20:09:57

  Modified:    .        STATUS
               t        params.c
  Log:
  Reviewed by:	joes
  add apreq_quote and apreq_quote_once tests.
  
  Revision  Changes    Path
  1.71      +1 -3      httpd-apreq-2/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/STATUS,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- STATUS	17 Jul 2004 17:05:27 -0000	1.70
  +++ STATUS	18 Jul 2004 03:09:57 -0000	1.71
  @@ -63,8 +63,6 @@
         -  apreq_merge_values()
         -  apreq_enctype()
         -  apreq_memmem()
  -      -  apreq_quote()
  -      -  apreq_quote_once()
         -  apreq_escape()
         -  apreq_encode_param()
   
  
  
  
  1.16      +29 -0     httpd-apreq-2/t/params.c
  
  Index: params.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/t/params.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- params.c	17 Jul 2004 17:05:27 -0000	1.15
  +++ params.c	18 Jul 2004 03:09:57 -0000	1.16
  @@ -125,6 +125,34 @@
       CuAssertStrEquals(tc, val, v2->data);
   }
   
  +static void quote_strings(CuTest *tc)
  +{
  +    apr_size_t exp_len, res_len, res_quote_len;
  +    char *res = apr_palloc(p,24);
  +    char *res_quote = apr_palloc(p,24);
  +    char *exp = apr_palloc(p,24);
  +    int i;
  +    char * arr[] = {"cest", "\"cest", "ce\"st", "\"cest\""};
  +    char * arr_quote[] = 
  +        {"\"cest\"", "\"\\\"cest\"", "\"ce\\\"st\"", "\"\\\"cest\\\"\""};
  +    apr_size_t arr_len[] = {4, 5, 5, 6};
  +    apr_size_t arr_quote_len[] = {6, 8, 8, 10};
  +
  +    for (i=0; i<4; i++) {
  +        res_len = apreq_quote(res, arr[i], arr_len[i]);
  +        CuAssertIntEquals(tc, arr_quote_len[i], res_len);
  +        CuAssertStrNEquals(tc, arr_quote[i], res, res_len);
  +        res_quote_len = apreq_quote_once(res_quote, res, res_len);
  +        CuAssertIntEquals(tc, res_len, res_quote_len);
  +        CuAssertStrNEquals(tc, res, res_quote, res_len);
  +        res_len = apreq_quote_once(res, arr[i], arr_len[i]);
  +        exp_len = (i == 3) ? arr_len[i] : arr_quote_len[i];
  +        exp = (i == 3) ? arr[i] : arr_quote[i];
  +        CuAssertIntEquals(tc, exp_len, res_len);
  +        CuAssertStrNEquals(tc, exp, res, exp_len);
  +    }
  +}
  +
   CuSuite *testparam(void)
   {
       CuSuite *suite = CuSuiteNew("Param");
  @@ -135,6 +163,7 @@
       SUITE_ADD_TEST(suite, string_decoding_in_place);
       SUITE_ADD_TEST(suite, header_attributes);
       SUITE_ADD_TEST(suite, make_values);
  +    SUITE_ADD_TEST(suite, quote_strings);
   
       return suite;
   }
  
  
  

Mime
View raw message