Changeset 8a33777 for tests/io


Ignore:
Timestamp:
Jan 24, 2024, 11:58:10 AM (5 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
3db78b89
Parents:
71b5aad5
Message:

Fix analysis error in string-input testing.

Add comments correlating .in file content with line of code that reads it.

This test's correctness expectation is bootstrapped from the actual behaviour of scanf.
A mistake in knowing "which character are we on at this point"
led to an inaccurate understanding of what scanf does on an edge case.
The test was showing that the CFA analogs behave the same as scanf.
But the test was not exercising the case that it suggested it was.
This issue is now fixed.

Old position, mistaken: case 14 begins on line ccccuuuucccc
Old position, corrected: cases 12/13 consume leading cccc; case 14 begins on uuuucccc
New positions: as commented in test .cfa

prior scanf understanding, mistaken: include skips unwanted characters before capturing
wanted characters, while exclude fails on unwanted characters

scanf understanding, corrected: include and exclude fail on unwanted characters

Location:
tests/io
Files:
5 edited

Legend:

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

    r71b5aad5 r8a33777  
    181812 wwwwwwww
    191913 wwwwwwww
    20 14 rc=1, cccc
     2014 rc=0, q
    212115 rc=0, q
    222216 get this line
     
    414112
    424213
    43 14 cccc
     4314
    444415
    454516 get this line
  • tests/io/.expect/manipulatorsInput.x64.txt

    r71b5aad5 r8a33777  
    181812 wwwwwwww
    191913 wwwwwwww
    20 14 rc=1, cccc
     2014 rc=0, q
    212115 rc=0, q
    222216 get this line
     
    414112
    424213
    43 14 cccc
     4314
    444415
    454516 get this line
  • tests/io/.expect/manipulatorsInput.x86.txt

    r71b5aad5 r8a33777  
    181812 wwwwwwww
    191913 wwwwwwww
    20 14 rc=1, cccc
     2014 rc=0, q
    212115 rc=0, q
    222216 get this line
     
    414112
    424213
    43 14 cccc
     4314
    444415
    454516 get this line
  • tests/io/.in/manipulatorsInput.txt

    r71b5aad5 r8a33777  
    88abcxxx
    99abcyyy
    10 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww
    11 uuuuuccccuuuuu
     10aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwwwaaaaaaaawwwwwwww
     11uuuuu
    1212get this line
    1313@# this line 1)-{}%
     
    2323abcxxx
    2424abcyyy
    25 aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww
    26 uuuuuccccuuuuu
     25aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwwwaaaaaaaawwwwwwww
     26uuuuu
    2727get this line
    2828@# this line 1)-{}%
  • tests/io/manipulatorsInput.cfa

    r71b5aad5 r8a33777  
    5555        }
    5656        {
    57                 char s[] = "yyyyyyyyyyyyyyyyyyyy";
     57                char s[] = "yyyyyyyyyyyyyyyyyyyy";                                                     // Input characters consumed:
    5858                const char sk_fmt[] = "%*[abc]";
    59                 scanf( "abc " ); scanf( sk_fmt ); for ( 5 ) scanf( "%*c" ); printf( "1 %s\n", s );
    60                 scanf( "%s", s );                                                               printf( "2 %s\n", s );
    61                 scanf( "%*s" );                                                                 printf( "3 %s\n", s );
    62                 scanf( "%8s", s );                                                              printf( "4 %s\n", s );
    63                 scanf( "%*8s" );                                                                printf( "5 %s\n", s );
    64 
    65                 scanf( "%[abc]", s );                                                   printf( "6 %s\n", s );
    66                 scanf( "%[^abc]", s );                                                  printf( "7 %s\n", s );
    67                 scanf( "%*[abc]" );                                                             printf( "8 %s\n", s );
    68                 scanf( "%*[^abc]" );                                                    printf( "9 %s\n", s );
    69                 scanf( "%8[abc]", s );                                                  printf( "10 %s\n", s );
    70                 scanf( "%8[^abc]", s );                                                 printf( "11 %s\n", s );
    71                 scanf( "%*8[abc]" );                                                    printf( "12 %s\n", s );
    72                 scanf( "%*8[^abc]" );                                                   printf( "13 %s\n", s );
     59                scanf( "abc " ); scanf( sk_fmt ); for ( 5 ) scanf( "%*c" ); printf( "1 %s\n", s );     // |abc |\ncccccb| \nxx\n|
     60                scanf( "%s", s );                                                               printf( "2 %s\n", s );                 // |abcxxx|
     61                scanf( "%*s" );                                                                 printf( "3 %s\n", s );                 // |\nabcyyy|
     62                scanf( "%8s", s );                                                              printf( "4 %s\n", s );                 // |\naaaaaaaa|
     63                scanf( "%*8s" );                                                                printf( "5 %s\n", s );                 // |xxxxxxxx|
     64
     65                scanf( "%[abc]", s );                                                   printf( "6 %s\n", s );                 // |aabbccbb|
     66                scanf( "%[^abc]", s );                                                  printf( "7 %s\n", s );                 // |dddwww|
     67                scanf( "%*[abc]" );                                                             printf( "8 %s\n", s );                 // |bbbbbbbb|
     68                scanf( "%*[^abc]" );                                                    printf( "9 %s\n", s );                 // |wwwwwwww|
     69                scanf( "%8[abc]", s );                                                  printf( "10 %s\n", s );                // |aaaaaaaa|
     70                scanf( "%8[^abc]", s );                                                 printf( "11 %s\n", s );                // |wwwwwwww|
     71                scanf( "%*8[abc]" );                                                    printf( "12 %s\n", s );                // |aaaaaaaa|
     72                scanf( "%*8[^abc]" );                                                   printf( "13 %s\n", s );                // |wwwwwwww|
     73                scanf( "\n" );                                                                  // must start next line                // |\n|
    7374
    7475                int rc;
    7576                s[0] = 'q'; s[1] = '\0'; rc = 99;
    76                 rc = scanf( "%[abc]", s );                                              printf( "14 rc=%d, %s\n", rc, s );
     77                rc = scanf( "%[abc]", s );                                              printf( "14 rc=%d, %s\n", rc, s );     // ||
    7778                s[0] = 'q'; s[1] = '\0'; rc = 99;
    78                 rc = scanf( "%[^u]", s );                                               printf( "15 rc=%d, %s\n", rc, s );
    79                 scanf( "%*[u]\n" );
    80                 scanf( "%[^\n]\n", s );                                                 printf( "16 %s\n", s );
    81                 scanf( "%[^%%]%%\n", s );                                               printf( "17 %s\n", s );
    82 
    83                 scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace
    84                 scanf( "\"%[^\"]\"", s );                                               printf( "18 %s\n", s );
    85                 scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace
    86                 scanf( "'%[^']'", s );                                                  printf( "19 %s\n", s );
    87                 scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace
    88                 scanf( "{%[^}]}", s );                                                  printf( "20 %s\n", s );
    89                 scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace
    90                 scanf( "X%[^Y]Y", s );                                                  printf( "21 %s\n", s );
    91                 scanf( "\n" );                                                                  // must start next line
     79                rc = scanf( "%[^u]", s );                                               printf( "15 rc=%d, %s\n", rc, s );     // ||
     80                scanf( "%*[u]\n" );                                                                    // |uuuuu\n|
     81                scanf( "%[^\n]\n", s );                                                 printf( "16 %s\n", s );                // |get this line\n|
     82                scanf( "%[^%%]%%\n", s );                                               printf( "17 %s\n", s );                // |@# this line 1)-{}%\n|
     83
     84                scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace                   // ||
     85                scanf( "\"%[^\"]\"", s );                                               printf( "18 %s\n", s );                // |"abc"|
     86                scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace                   // |\n|
     87                scanf( "'%[^']'", s );                                                  printf( "19 %s\n", s );                // |'abc  '|
     88                scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace                   // |\n|
     89                scanf( "{%[^}]}", s );                                                  printf( "20 %s\n", s );                // |{ d d\n\nd }|
     90                scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace                   // |\n|
     91                scanf( "X%[^Y]Y", s );                                                  printf( "21 %s\n", s );                // |X            ZC44%Y|
     92                scanf( "\n" );                                                                  // must start next line                // |\n|
    9293        }
    9394        {
     
    108109                sin | ignore( incl( "abc", wdi( sizeof(s), 8, s ) ) ); sout | "12" | s;
    109110                sin | ignore( excl( "abc", wdi( sizeof(s), 8, s ) ) ); sout | "13" | s;
     111                sin | "\n";
    110112
    111113                s[0] = 'q'; s[1] = '\0';
Note: See TracChangeset for help on using the changeset viewer.