Add test cases for escaped whitespace within single- and double-quoted

strings.  This reveals a bug relating to line continuations within
double-quoted strings.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@584 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2012-04-07 22:47:16 +00:00
parent 4c0e839be3
commit 53544bd288
1 changed files with 39 additions and 2 deletions

View File

@ -396,11 +396,13 @@ T_FUNC(escaped_whitespace, "escaped whitespace")
int ret;
orw_open();
orw_output("\\ \\\t \\\r\n");
orw_output("\\ \\\t \\\r \\\n\n");
orw_rewind();
ret = orw_expect(" ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
orw_expect("\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
orw_expect("\r", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
orw_expect("\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
/* this last one is a line continuation */
orw_expect(NULL, 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
orw_close();
return (ret);
}
@ -615,6 +617,39 @@ T_FUNC(escaped_double_quote,
return (ret);
}
T_FUNC(escaped_whitespace_within_single_quotes,
"escaped whitespace within single quotes")
{
int ret;
orw_open();
orw_output("'\\ ' '\\\t' '\\\r' '\\\n'\n");
orw_rewind();
ret = orw_expect("\\ ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
orw_expect("\\\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
orw_expect("\\\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
orw_expect("\\\n", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
orw_close();
return (ret);
}
T_FUNC(escaped_whitespace_within_double_quotes,
"escaped whitespace within double quotes")
{
int ret;
orw_open();
orw_output("\"\\ \" \"\\\t\" \"\\\r\" \"\\\n\"\n");
orw_rewind();
ret = orw_expect("\\ ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
orw_expect("\\\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
orw_expect("\\\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
/* this last one is a line continuation */
orw_expect("", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
orw_close();
return (ret);
}
T_FUNC(escaped_letter_within_single_quotes,
"escaped letter within single quotes")
{
@ -762,6 +797,8 @@ const struct t_test *t_plan[] = {
T(escaped_single_quote),
T(escaped_double_quote),
T(escaped_whitespace_within_single_quotes),
T(escaped_whitespace_within_double_quotes),
T(escaped_letter_within_single_quotes),
T(escaped_letter_within_double_quotes),
T(escaped_escape_within_single_quotes),