chore: cover every reachable branch and drop the unreachable ones - #82
Merged
Merged
Conversation
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.
Coverage goes from 97.7% to 99.8%. The one statement left is the error return from
html.Parse. It only fails when its reader does, and astrings.Readernever fails, but Go has no way to exclude a line from coverage and discarding the error would be worse.Removed as unreachable:
n == nilguard indoConvert. No caller passes nil.breaks inextractPreandrestorePre. Both now usestrings.Cut, since the markers are always written in pairs and one placeholder is written per block. Merge fix: keep control characters in content from acting as markers #81 first, because that is what stops content from injecting unpaired markers.target >= totalinWordWrap. The loop only runs whileendRune + lineLength < total, so it never held. The remaining clamp is a singlemax.New tests for branches that were reachable but untested:
<br>inside<pre><img>nested inside an element within a linkstylewith a trailing;WordWrappast a run of spaces longer than the line)whose only earlier break is the one being movedThe new
WordWrapwas compared against the one on main over 300,000 random inputs covering brackets, runs of spaces, multi-byte runes and widths from -1 to 10, and output was identical. Output is byte-for-byte identical to main across the corpus under every link style.FuzzFixSpacingpasses.