Add a test for lines containing more words than will fit in

openpam_readword()'s initial allocation.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@793 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2014-03-17 14:27:03 +00:00
parent e58f05403e
commit b61b6f9c74
1 changed files with 34 additions and 0 deletions

View File

@ -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