Input boundary prediction practice
Predict first, then compare the calibration.
- Capacity 1: distinguish empty input from a single newline.
- Capacity 4: compare
abcplus newline withabcdplus newline. - Capacity 2: an overlong line is followed by
qplus newline. What must the next call return? - A source delivers byte 255 then end. Why must the source result stay in int?
- A line contains NUL, then the source fails. Which status wins?
- Why might a reader that returns early on an overlong line pass a sanitizer check?
Calibration
- EOF versus OK with an empty terminated string.
- OK with abc versus LONG; both consume the delimiter.
- OK with q, because rejected input was drained.
- A byte must remain distinguishable from a negative end sentinel. Narrowing first can destroy that distinction.
- IO_ERROR; the reader clears buf[0] and returns immediately.
- It may access only valid storage while violating the source-position contract. Assertions on consecutive calls detect that logical error.
Repeat after a delay with a changed capacity and an unterminated final line. Do not treat recalled answers as independent transfer.