Changeset 584 in openpam


Ignore:
Timestamp:
Apr 7, 2012, 10:47:16 PM (3 years ago)
Author:
des
Message:

Add test cases for escaped whitespace within single- and double-quoted
strings. This reveals a bug relating to line continuations within
double-quoted strings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/t_openpam_readword.c

    r578 r584  
    400400
    401401        orw_open();
    402         orw_output("\\  \\\t \\\r\n");
     402        orw_output("\\  \\\t \\\r \\\n\n");
    403403        orw_rewind();
    404404        ret = orw_expect(" ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
    405405            orw_expect("\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
    406             orw_expect("\r", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
     406            orw_expect("\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
     407            /* this last one is a line continuation */
     408            orw_expect(NULL, 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
    407409        orw_close();
    408410        return (ret);
     
    617619        orw_rewind();
    618620        ret = orw_expect("\"", 0 /*lines*/, 0 /*eof*/, 1 /*eol*/);
     621        orw_close();
     622        return (ret);
     623}
     624
     625T_FUNC(escaped_whitespace_within_single_quotes,
     626    "escaped whitespace within single quotes")
     627{
     628        int ret;
     629
     630        orw_open();
     631        orw_output("'\\ ' '\\\t' '\\\r' '\\\n'\n");
     632        orw_rewind();
     633        ret = orw_expect("\\ ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
     634            orw_expect("\\\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
     635            orw_expect("\\\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
     636            orw_expect("\\\n", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
     637        orw_close();
     638        return (ret);
     639}
     640
     641T_FUNC(escaped_whitespace_within_double_quotes,
     642    "escaped whitespace within double quotes")
     643{
     644        int ret;
     645
     646        orw_open();
     647        orw_output("\"\\ \" \"\\\t\" \"\\\r\" \"\\\n\"\n");
     648        orw_rewind();
     649        ret = orw_expect("\\ ", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
     650            orw_expect("\\\t", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
     651            orw_expect("\\\r", 0 /*lines*/, 0 /*eof*/, 0 /*eol*/) &&
     652            /* this last one is a line continuation */
     653            orw_expect("", 1 /*lines*/, 0 /*eof*/, 1 /*eol*/);
    619654        orw_close();
    620655        return (ret);
     
    769804        T(escaped_single_quote),
    770805        T(escaped_double_quote),
     806        T(escaped_whitespace_within_single_quotes),
     807        T(escaped_whitespace_within_double_quotes),
    771808        T(escaped_letter_within_single_quotes),
    772809        T(escaped_letter_within_double_quotes),
Note: See TracChangeset for help on using the changeset viewer.