Changeset 0860d9c for tests/io


Ignore:
Timestamp:
Oct 5, 2023, 4:17:14 PM (15 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
4d860ea3
Parents:
b67b632
Message:

Fix read-to-variable-length-string cases when internal buffer fills.

Also fix read-to-cstring ability to give no-exception cases when an entire buffer fills.

The added test cases run, and fail, when run against prior libcfa.
Doing so illustrates a CFA-string-level bug.
Doing so illustrates a C-string-level changed semantics.

At the CFA-string level, the bug was, when reading strings of just the right length,
what should be two reads ("abc" then "def") gets mashed into one ("abcdef").
These cases are clearly bugs because a test program that just echoes chuncks of delimeted input would do so inaccurately.
They're just hard to drive because the relevant chunk lengths are implementation-dependent, and sometimes big.

At the C-string level, the semantic change concerns when to throw the cstring_length exception.
By this change, make the original semantics,
"An exception means the maximum number of characters was read," into
"An exception means that if the buffer were larger, then more characters would have been read."

The added test cases cover the respective stop conditions for manipulator state "%s", include, exclude, getline, and getline/delimiter.

Location:
tests/io
Files:
5 edited

Legend:

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

    rb67b632 r0860d9c  
    11pre1 "123456", canary ok
    2 pre2a "1234567", exception occurred, canary ok
    3 pre2b "89", canary ok
     2pre2 "1234567", canary ok
     3pre3a "1234567", exception occurred, canary ok
     4pre3b "8", canary ok
     5pre4a "1234567", exception occurred, canary ok
     6pre4b "89", canary ok
    471 yyyyyyyyyyyyyyyyyyyy
    582 abcxxx
  • tests/io/.expect/manipulatorsInput.x64.txt

    rb67b632 r0860d9c  
    11pre1 "123456", canary ok
    2 pre2a "1234567", exception occurred, canary ok
    3 pre2b "89", canary ok
     2pre2 "1234567", canary ok
     3pre3a "1234567", exception occurred, canary ok
     4pre3b "8", canary ok
     5pre4a "1234567", exception occurred, canary ok
     6pre4b "89", canary ok
    471 yyyyyyyyyyyyyyyyyyyy
    582 abcxxx
  • tests/io/.expect/manipulatorsInput.x86.txt

    rb67b632 r0860d9c  
    11pre1 "123456", canary ok
    2 pre2a "1234567", exception occurred, canary ok
    3 pre2b "89", canary ok
     2pre2 "1234567", canary ok
     3pre3a "1234567", exception occurred, canary ok
     4pre3b "8", canary ok
     5pre4a "1234567", exception occurred, canary ok
     6pre4b "89", canary ok
    471 yyyyyyyyyyyyyyyyyyyy
    582 abcxxx
  • tests/io/.in/manipulatorsInput.txt

    rb67b632 r0860d9c  
    11123456
     21234567
     312345678
    24123456789
    35abc
  • tests/io/manipulatorsInput.cfa

    rb67b632 r0860d9c  
    4545                }
    4646
    47                 rep("pre1");
    48                 rep("pre2a");
    49                 rep("pre2b");
     47                rep("pre1");    // 123456     |  123456
     48                rep("pre2");    // 1234567    |  1234567
     49                rep("pre3a");   // 12345678   |  1234567
     50                rep("pre3b");   //            |  8
     51                rep("pre4a");   // 123456789  |  1234567
     52                rep("pre4b");   //            |  89
     53
    5054                scanf("\n");  // next test does not start with %s so does not tolerate leading whitespace
    5155        }
Note: See TracChangeset for help on using the changeset viewer.