Repository navigation
test(segment): cover override bounds, a pending byte and an empty piece - #285
Merged
Merged
Conversation
Work in progress: not built or run yet. Mutants for each gap are in out/drafts/mutants-gaps.sh and have not run.
siracozmen01
commented
Nov 8, 2026
siracozmen01
left a comment
Contributor
Author
There was a problem hiding this comment.
Review at e7ea8ba: ready, once CI goes green. I read the tests against include/maul-unicode/segment.h; I did not run the mutants.
Each new check expects the documented result, not just a failure:
- Override bounds.
SetBreakClassOverridesdocumentsmuni_errorInvalidfor "a code point past U+10FFFF or a surrogate". U+DFFF expects exactly that. U+E000 and U+10FFFF, in strictly increasing order with a valid Sentence_Break class, expectmuni_success. ThecodePoint >= 0xD800mutant fails the second. - Feed.
Feed(nullptr, ...)expectsmuni_errorInvalid("a NULL argument"). The empty last piece (NULL, 0, false, which the header allows: "May be NULL when length is 0") expectsmuni_success, thenNextBreakgivesmuni_successwithoffset == 2, the end of "ab". The firstNextBreakreturnedmuni_needMoreText, so no boundary came before it. That checks the value, not just that the call works. - The pending byte. The text so far is
\xE0with more to follow, then\xA0\x80as the last piece. The iterator does not hold its whole text, soFindBreaksAroundmust answermuni_errorStateand leave both outputs "as it was unless the call returnsmuni_success".beforeandafterare 7 from the earlier refusal and are checked to still be 7. A mutant that reads the last piece as the whole text would return success there and fail.
The body has Problem, Change and Verification, and no column-0 name( line.
No findings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Source coverage of the suites at 0c2c23a found three refusals in
src/segment.cthat a host reaches through the public API with no test behind them. A mutant that weakens each one still passes every suite:ValidOverridesnever sees an override above U+DFFF, socodePoint >= 0xD800alone, which would refuse every override from U+E000 up, survives. The edges U+DFFF and U+10FFFF are untested too.muniSegmentIterator_FindBreaksAroundis never called with a byte pending from an earlier piece while the cursor is still at offset 0, so droppingpendingCount != 0survives and the call would read the last piece as the whole text.muniSegmentIterator_Feedis never called with a NULL iterator, nor with an empty last piece (NULL and 0), so refusing every NULL piece survives.Change
Tests only, in
test/test_segment.c:Feedrefuses a NULL iterator, and an empty last piece ends the text with the break at its end.FindBreaksAroundreturnmuni_errorStateand leave its outputs alone.Verification
tools/check.sh prpasses.Closes #283