Changeset 8cffa4f for tests/io


Ignore:
Timestamp:
Oct 5, 2023, 2:30:54 PM (15 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
b67b632
Parents:
bf1cbde
Message:

Support match-failure reporting for string input.

On failed match, assign the empty-string value to the target.
Prior handling did not modify the target,
which in context like char s[10]; sin | exclude("\n", s);,
left s uninitialized, and invalid for strlen, when the input's next character is a newline.
In this case, scanf offers the return value, the count of output arguments written,
to say, "I did not write to your buffer," a feature lost in the pipe abstraction.

Add tests to exercise such cases.

(Prior "leave uninitialized" treatment was discovered by surprise, while debugging a test program for an upcoming commit.)

Location:
tests/io
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • tests/io/.expect/manipulatorsInput.arm64.txt

    rbf1cbde r8cffa4f  
    151512 wwwwwwww
    161613 wwwwwwww
     1714 rc=1, cccc
     1815 rc=0, q
    17191 yyyyyyyyyyyyyyyyyyyy
    18202 abcxxx
     
    283012 wwwwwwww
    293113 wwwwwwww
     3214 cccc
     3315
    3034a
    3135a
  • tests/io/.expect/manipulatorsInput.x64.txt

    rbf1cbde r8cffa4f  
    151512 wwwwwwww
    161613 wwwwwwww
     1714 rc=1, cccc
     1815 rc=0, q
    17191 yyyyyyyyyyyyyyyyyyyy
    18202 abcxxx
     
    283012 wwwwwwww
    293113 wwwwwwww
     3214 cccc
     3315
    3034a
    3135a
  • tests/io/.expect/manipulatorsInput.x86.txt

    rbf1cbde r8cffa4f  
    151512 wwwwwwww
    161613 wwwwwwww
     1714 rc=1, cccc
     1815 rc=0, q
    17191 yyyyyyyyyyyyyyyyyyyy
    18202 abcxxx
     
    283012 wwwwwwww
    293113 wwwwwwww
     3214 cccc
     3315
    3034a
    3135a
  • tests/io/.in/manipulatorsInput.txt

    rbf1cbde r8cffa4f  
    77abcyyy
    88aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww
     9uuuuuccccuuuuu
    910abc
    1011cccccb
     
    1314abcyyy
    1415aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww
     16uuuuuccccuuuuu
    1517ab
    16180xff 017 15-15
  • tests/io/manipulatorsInput.cfa

    rbf1cbde r8cffa4f  
    6767                scanf( "%*8[abc]" );                                                    printf( "12 %s\n", s );
    6868                scanf( "%*8[^abc]" );                                                   printf( "13 %s\n", s );
     69
     70                int rc;
     71                s[0] = 'q'; s[1] = '\0'; rc = 99;
     72                rc = scanf( "%[abc]", s );                                              printf( "14 rc=%d, %s\n", rc, s );
     73                s[0] = 'q'; s[1] = '\0'; rc = 99;
     74                rc = scanf( "%[^u]", s );                                               printf( "15 rc=%d, %s\n", rc, s );
     75                scanf( "%*[u]" );
     76                scanf("\n");
    6977        }
    7078        {
     
    8593                sin | ignore( incl( "abc", wdi( sizeof(s), 8, s ) ) ); sout | "12" | s;
    8694                sin | ignore( excl( "abc", wdi( sizeof(s), 8, s ) ) ); sout | "13" | s;
     95
     96                s[0] = 'q'; s[1] = '\0';
     97                sin | incl( "abc", wdi( sizeof(s), s ) );               sout | "14" | s;
     98                s[0] = 'q'; s[1] = '\0';
     99                sin | excl( "u", wdi( sizeof(s), s ) );                 sout | "15" | s;
     100                sin | skip( "u" );
     101                sin | "\n";
    87102        }
    88103    /* Keep harmonized with collections/string-istream-manip */
Note: See TracChangeset for help on using the changeset viewer.