Changeset 790 in openpam


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

Additional tests for various end-of-line / end-of-file corner cases,
and for comments that aren't comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/t_openpam_readword.c

    r648 r790  
    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
     
    836915        T(single_whitespace),
    837916        T(multiple_whitespace),
     917        T(line_continuation_in_whitespace),
    838918        T(comment),
    839919        T(whitespace_before_comment),
     920        T(single_quoted_comment),
     921        T(double_quoted_comment),
     922        T(comment_at_eof),
    840923
    841924        T(single_word),
     
    855938        T(escaped_newline_after_word),
    856939        T(escaped_letter),
     940        T(escaped_comment),
     941        T(escape_at_eof),
    857942
    858943        T(naked_single_quote),
Note: See TracChangeset for help on using the changeset viewer.