Changeset 793 in openpam


Ignore:
Timestamp:
Mar 17, 2014, 2:27:03 PM (7 years ago)
Author:
Dag-Erling Smørgrav
Message:

Add a test for lines containing more words than will fit in
openpam_readword()'s initial allocation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/t_openpam_readlinev.c

    r648 r793  
    127127};
    128128
     129static const char *numbers[] = {
     130        "zero", "one", "two", "three", "four", "five", "six", "seven",
     131        "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen",
     132        "fifteen", "sixteen", "seventeen", "nineteen", "twenty",
     133        "twenty-one", "twenty-two", "twenty-three", "twenty-four",
     134        "twenty-five", "twenty-six", "twenty-seven", "twenty-eight",
     135        "twenty-nine", "thirty", "thirty-one", "thirty-two", "thirty-three",
     136        "thirty-four", "thirty-five", "thirty-six", "thirty-seven",
     137        "thirty-eight", "thirty-nine", "fourty", "fourty-one", "fourty-two",
     138        "fourty-three", "fourty-four", "fourty-five", "fourty-six",
     139        "fourty-seven", "fourty-eight", "fourty-nine", "fifty", "fifty-one",
     140        "fifty-two", "fifty-three", "fifty-four", "fifty-five", "fifty-six",
     141        "fifty-seven", "fifty-eight", "fifty-nine", "sixty", "sixty-one",
     142        "sixty-two", "sixty-three",
     143        NULL
     144};
     145
    129146
    130147
     
    237254        t_frewind(tf);
    238255        ret = orlv_expect(tf, hello_world, 1 /*lines*/, 0 /*eof*/);
     256        t_fclose(tf);
     257        return (ret);
     258}
     259
     260T_FUNC(many_words, "many words")
     261{
     262        struct t_file *tf;
     263        const char **word;
     264        int ret;
     265
     266        tf = t_fopen(NULL);
     267        for (word = numbers; *word; ++word)
     268                t_fprintf(tf, " %s", *word);
     269        t_fprintf(tf, "\n");
     270        t_frewind(tf);
     271        ret = orlv_expect(tf, numbers, 1 /*lines*/, 0 /*eof*/);
    239272        t_fclose(tf);
    240273        return (ret);
     
    270303        T(one_word),
    271304        T(two_words),
     305        T(many_words),
    272306        T(unterminated_line),
    273307
Note: See TracChangeset for help on using the changeset viewer.