merge r790, r791: additional tests for openpam_readword()
merge r793: additional tests for openpam_readlinev() git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/branches/nooath@826 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
918f37acdc
commit
9700f8606d
|
@ -125,6 +125,23 @@ static const char *hello_world[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static const char *numbers[] = {
|
||||
"zero", "one", "two", "three", "four", "five", "six", "seven",
|
||||
"eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen",
|
||||
"fifteen", "sixteen", "seventeen", "nineteen", "twenty",
|
||||
"twenty-one", "twenty-two", "twenty-three", "twenty-four",
|
||||
"twenty-five", "twenty-six", "twenty-seven", "twenty-eight",
|
||||
"twenty-nine", "thirty", "thirty-one", "thirty-two", "thirty-three",
|
||||
"thirty-four", "thirty-five", "thirty-six", "thirty-seven",
|
||||
"thirty-eight", "thirty-nine", "fourty", "fourty-one", "fourty-two",
|
||||
"fourty-three", "fourty-four", "fourty-five", "fourty-six",
|
||||
"fourty-seven", "fourty-eight", "fourty-nine", "fifty", "fifty-one",
|
||||
"fifty-two", "fifty-three", "fifty-four", "fifty-five", "fifty-six",
|
||||
"fifty-seven", "fifty-eight", "fifty-nine", "sixty", "sixty-one",
|
||||
"sixty-two", "sixty-three",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Lines without words
|
||||
|
@ -237,6 +254,22 @@ T_FUNC(two_words, "two words")
|
|||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(many_words, "many words")
|
||||
{
|
||||
struct t_file *tf;
|
||||
const char **word;
|
||||
int ret;
|
||||
|
||||
tf = t_fopen(NULL);
|
||||
for (word = numbers; *word; ++word)
|
||||
t_fprintf(tf, " %s", *word);
|
||||
t_fprintf(tf, "\n");
|
||||
t_frewind(tf);
|
||||
ret = orlv_expect(tf, numbers, 1 /*lines*/, 0 /*eof*/);
|
||||
t_fclose(tf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(unterminated_line, "unterminated line")
|
||||
{
|
||||
struct t_file *tf;
|
||||
|
@ -265,6 +298,7 @@ const struct t_test *t_plan[] = {
|
|||
|
||||
T(one_word),
|
||||
T(two_words),
|
||||
T(many_words),
|
||||
T(unterminated_line),
|
||||
|
||||
NULL
|
||||
|
|
|
@ -169,6 +169,19 @@ T_FUNC(multiple_whitespace, "multiple whitespace")
|
|||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(line_continuation_in_whitespace, "line continuation in whitespace")
|
||||
{
|
||||
struct t_file *tf;
|
||||
int ret;
|
||||
|
||||
tf = t_fopen(NULL);
|
||||
t_fprintf(tf, " \\\n \n");
|
||||
t_frewind(tf);
|
||||
ret = orw_expect(tf, NULL, 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
|
||||
t_fclose(tf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(comment, "comment")
|
||||
{
|
||||
struct t_file *tf;
|
||||
|
@ -195,6 +208,45 @@ T_FUNC(whitespace_before_comment, "whitespace before comment")
|
|||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(single_quoted_comment, "single-quoted comment")
|
||||
{
|
||||
struct t_file *tf;
|
||||
int ret;
|
||||
|
||||
tf = t_fopen(NULL);
|
||||
t_fprintf(tf, " '# comment'\n");
|
||||
t_frewind(tf);
|
||||
ret = orw_expect(tf, "# comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
|
||||
t_fclose(tf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(double_quoted_comment, "double-quoted comment")
|
||||
{
|
||||
struct t_file *tf;
|
||||
int ret;
|
||||
|
||||
tf = t_fopen(NULL);
|
||||
t_fprintf(tf, " \"# comment\"\n");
|
||||
t_frewind(tf);
|
||||
ret = orw_expect(tf, "# comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
|
||||
t_fclose(tf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(comment_at_eof, "comment at end of file")
|
||||
{
|
||||
struct t_file *tf;
|
||||
int ret;
|
||||
|
||||
tf = t_fopen(NULL);
|
||||
t_fprintf(tf, "# comment");
|
||||
t_frewind(tf);
|
||||
ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
|
||||
t_fclose(tf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Simple cases - no quotes or escapes
|
||||
|
@ -414,6 +466,33 @@ T_FUNC(escaped_letter, "escaped letter")
|
|||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(escaped_comment, "escaped comment")
|
||||
{
|
||||
struct t_file *tf;
|
||||
int ret;
|
||||
|
||||
tf = t_fopen(NULL);
|
||||
t_fprintf(tf, " \\# comment\n");
|
||||
t_frewind(tf);
|
||||
ret = orw_expect(tf, "#", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
|
||||
orw_expect(tf, "comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
|
||||
t_fclose(tf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
T_FUNC(escape_at_eof, "escape at end of file")
|
||||
{
|
||||
struct t_file *tf;
|
||||
int ret;
|
||||
|
||||
tf = t_fopen(NULL);
|
||||
t_fprintf(tf, "z\\");
|
||||
t_frewind(tf);
|
||||
ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
|
||||
t_fclose(tf);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Quotes
|
||||
|
@ -826,10 +905,15 @@ T_FUNC(escaped_double_quote_within_double_quotes,
|
|||
const struct t_test *t_plan[] = {
|
||||
T(empty_input),
|
||||
T(empty_line),
|
||||
T(unterminated_line),
|
||||
T(single_whitespace),
|
||||
T(multiple_whitespace),
|
||||
T(line_continuation_in_whitespace),
|
||||
T(comment),
|
||||
T(whitespace_before_comment),
|
||||
T(single_quoted_comment),
|
||||
T(double_quoted_comment),
|
||||
T(comment_at_eof),
|
||||
|
||||
T(single_word),
|
||||
T(single_whitespace_before_word),
|
||||
|
@ -847,6 +931,8 @@ const struct t_test *t_plan[] = {
|
|||
T(escaped_newline_within_word),
|
||||
T(escaped_newline_after_word),
|
||||
T(escaped_letter),
|
||||
T(escaped_comment),
|
||||
T(escape_at_eof),
|
||||
|
||||
T(naked_single_quote),
|
||||
T(naked_double_quote),
|
||||
|
|
Loading…
Reference in New Issue