You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Randy Kobes <ra...@theoryx5.uwinnipeg.ca> on 2004/07/18 00:27:20 UTC
quote/quote_once tests
Here's some tests for the quote/quote_once functions:
===========================================================
Index: STATUS
===================================================================
RCS file: /home/cvs/httpd-apreq-2/STATUS,v
retrieving revision 1.70
diff -u -r1.70 STATUS
--- STATUS 17 Jul 2004 17:05:27 -0000 1.70
+++ STATUS 17 Jul 2004 22:22:28 -0000
@@ -63,8 +63,6 @@
- apreq_merge_values()
- apreq_enctype()
- apreq_memmem()
- - apreq_quote()
- - apreq_quote_once()
- apreq_escape()
- apreq_encode_param()
Index: t/params.c
===================================================================
RCS file: /home/cvs/httpd-apreq-2/t/params.c,v
retrieving revision 1.15
diff -u -r1.15 params.c
--- t/params.c 17 Jul 2004 17:05:27 -0000 1.15
+++ t/params.c 17 Jul 2004 22:22:29 -0000
@@ -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;
}
===================================================================
--
best regards,
randy
Re: quote/quote_once tests
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Sat, 17 Jul 2004, Joe Schaefer wrote:
> Randy Kobes <ra...@theoryx5.uwinnipeg.ca> writes:
>
> > Here's some tests for the quote/quote_once functions:
>
> +1.
>
> [...]
>
> > + char * arr[] = {"cest", "\"cest", "ce\"st", "\"cest\""};
> > + char * arr_quote[] =
> > + {"\"cest\"", "\"\\\"cest\"", "\"ce\\\"st\"", "\"\\\"cest\\\"\""};
>
> Good lord, and it passes the tests?
I hope so :) They did for me - let me know if there's
problems ...
--
best regards,
randy
Re: quote/quote_once tests
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Randy Kobes <ra...@theoryx5.uwinnipeg.ca> writes:
> Here's some tests for the quote/quote_once functions:
+1.
[...]
> + char * arr[] = {"cest", "\"cest", "ce\"st", "\"cest\""};
> + char * arr_quote[] =
> + {"\"cest\"", "\"\\\"cest\"", "\"ce\\\"st\"", "\"\\\"cest\\\"\""};
Good lord, and it passes the tests?
--
Joe Schaefer