Changeset 826 in openpam for branches/nooath


Ignore:
Timestamp:
Oct 18, 2014, 10:42:23 PM (7 years ago)
Author:
Dag-Erling Smørgrav
Message:

merge r790, r791: additional tests for openpam_readword()
merge r793: additional tests for openpam_readlinev()

Location:
branches/nooath
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/nooath

  • branches/nooath/t/t_openpam_readlinev.c

    r648 r826  
    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
  • branches/nooath/t/t_openpam_readword.c

    r648 r826  
    171171}
    172172
     173T_FUNC(line_continuation_in_whitespace, "line continuation in whitespace")
     174{
     175        struct t_file *tf;
     176        int ret;
     177
     178        tf = t_fopen(NULL);
     179        t_fprintf(tf, " \\\n \n");
     180        t_frewind(tf);
     181        ret = orw_expect(tf, NULL, 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
     182        t_fclose(tf);
     183        return (ret);
     184}
     185
    173186T_FUNC(comment, "comment")
    174187{
     
    193206        t_frewind(tf);
    194207        ret = orw_expect(tf, NULL, 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
     208        t_fclose(tf);
     209        return (ret);
     210}
     211
     212T_FUNC(single_quoted_comment, "single-quoted comment")
     213{
     214        struct t_file *tf;
     215        int ret;
     216
     217        tf = t_fopen(NULL);
     218        t_fprintf(tf, " '# comment'\n");
     219        t_frewind(tf);
     220        ret = orw_expect(tf, "# comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
     221        t_fclose(tf);
     222        return (ret);
     223}
     224
     225T_FUNC(double_quoted_comment, "double-quoted comment")
     226{
     227        struct t_file *tf;
     228        int ret;
     229
     230        tf = t_fopen(NULL);
     231        t_fprintf(tf, " \"# comment\"\n");
     232        t_frewind(tf);
     233        ret = orw_expect(tf, "# comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
     234        t_fclose(tf);
     235        return (ret);
     236}
     237
     238T_FUNC(comment_at_eof, "comment at end of file")
     239{
     240        struct t_file *tf;
     241        int ret;
     242
     243        tf = t_fopen(NULL);
     244        t_fprintf(tf, "# comment");
     245        t_frewind(tf);
     246        ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
    195247        t_fclose(tf);
    196248        return (ret);
     
    418470}
    419471
     472T_FUNC(escaped_comment, "escaped comment")
     473{
     474        struct t_file *tf;
     475        int ret;
     476
     477        tf = t_fopen(NULL);
     478        t_fprintf(tf, " \\# comment\n");
     479        t_frewind(tf);
     480        ret = orw_expect(tf, "#", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
     481            orw_expect(tf, "comment", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
     482        t_fclose(tf);
     483        return (ret);
     484}
     485
     486T_FUNC(escape_at_eof, "escape at end of file")
     487{
     488        struct t_file *tf;
     489        int ret;
     490
     491        tf = t_fopen(NULL);
     492        t_fprintf(tf, "z\\");
     493        t_frewind(tf);
     494        ret = orw_expect(tf, NULL, 0 /*lines*/, 1 /*eof*/, 0 /*eol*/);
     495        t_fclose(tf);
     496        return (ret);
     497}
     498
    420499
    421500
     
    834913        T(empty_input),
    835914        T(empty_line),
     915        T(unterminated_line),
    836916        T(single_whitespace),
    837917        T(multiple_whitespace),
     918        T(line_continuation_in_whitespace),
    838919        T(comment),
    839920        T(whitespace_before_comment),
     921        T(single_quoted_comment),
     922        T(double_quoted_comment),
     923        T(comment_at_eof),
    840924
    841925        T(single_word),
     
    855939        T(escaped_newline_after_word),
    856940        T(escaped_letter),
     941        T(escaped_comment),
     942        T(escape_at_eof),
    857943
    858944        T(naked_single_quote),
Note: See TracChangeset for help on using the changeset viewer.