Skip to content

chore: cover every reachable branch and drop the unreachable ones - #82

Merged
hownowstephen merged 1 commit into
mainfrom
chore_full_coverage
Sep 23, 2026
Merged

hownowstephen merged 1 commit into
mainfrom
chore_full_coverage

Conversation

@hownowstephen

Copy link
Copy Markdown
Contributor

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 a strings.Reader never fails, but Go has no way to exclude a line from coverage and discarding the error would be worse.

Removed as unreachable:

  • the n == nil guard in doConvert. No caller passes nil.
  • the missing-marker breaks in extractPre and restorePre. Both now use strings.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 >= total in WordWrap. The loop only runs while endRune + lineLength < total, so it never held. The remaining clamp is a single max.

New tests for branches that were reachable but untested:

  • <br> inside <pre>
  • an empty anchor with footnote links
  • an <img> nested inside an element within a link
  • a style with a trailing ;
  • WordWrap past a run of spaces longer than the line
  • a ) whose only earlier break is the one being moved

The new WordWrap was 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. FuzzFixSpacing passes.

@hownowstephen
hownowstephen marked this pull request as ready for review September 23, 2026 04:38
@hownowstephen
hownowstephen merged commit ba12973 into main Sep 23, 2026
2 checks passed
@hownowstephen
hownowstephen deleted the chore_full_coverage branch September 23, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant