Changeset 826 in openpam for branches/nooath/t/t_openpam_readword.c


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:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/nooath

  • 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.