Skip to content

Cover error paths: library coverage past 90%#21

Merged
pgundlach merged 2 commits into
mainfrom
claude/cover-error-paths
Jun 23, 2026
Merged

Cover error paths: library coverage past 90%#21
pgundlach merged 2 commits into
mainfrom
claude/cover-error-paths

Conversation

@fank

@fank fank commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Third coverage batch (follows #19, #20): error-path tests to take the library
packages over 90%
. Characterization tests only — no production code changed.

Result

Library coverage (internal/* + contentstream + main package) 87.1% → 90.1%.

package before after
internal/crypt 87.5% 91.1%
internal/lex 90.9% 90.9%
internal/filter 94.9% 94.9%
contentstream 82.3% 88.2%
main package 85.5% 89.1%

go vet / gofmt clean; all tests pass.

Covered (untrusted-input error handling)

  • reader: typed Resolve* type mismatches, OpenFile failures, rich DocumentInfo fields, Objects iteration, dangling-reference → null, xrefFormat
  • parse: malformed-token error branches (stray / keyword / unterminated / bad key)
  • filter: /F+/DP abbreviations, malformed and unsupported filter chains
  • contentstream: inline-image errors, stray delimiters, readDict errors, trailing-operand drop, All early-break, fake-EI-in-data scan
  • crypt: unsupported /V, /V5 via New, Identity stream override
  • object: typed-getter misses; dump: looksLikeText, xrefFormat

Not chased (by design)

The aggregate go test ./... number stays ~87.5% — examples/ demos and the cmd main() wrapper are vanity targets (their run() logic is already covered). Still deferred: the LZW early-change=1 boundary, which needs a real qpdf/Ghostscript fixture for an independent oracle.

fank added 2 commits June 23, 2026 11:57
Characterization tests for untrusted-input error handling across the library
packages (87.1% -> 90.1% statements); no production code changed.

- reader: typed Resolve* type errors, OpenFile failures, rich DocumentInfo
  fields, Objects iteration, dangling-reference null, xrefFormat
- parse: malformed-token error branches (stray/keyword/unterminated/bad key)
- filter: /F+/DP abbreviations, malformed and unsupported filter chains
- contentstream: inline-image errors, stray delimiters, readDict errors,
  trailing-operand drop, All early-break, fake-EI scan
- crypt: unsupported /V, /V5 via New, Identity stream override
- object: typed-getter misses; dump: looksLikeText, xrefFormat
looksLikeText: drop the rule list the named cases already show, keep the
non-obvious high-byte magic values. parseObjectFrom: drop the meta parenthetical.
@fank fank marked this pull request as ready for review June 23, 2026 10:02
@fank fank requested a review from pgundlach June 23, 2026 10:02
@pgundlach pgundlach merged commit b76486b into main Jun 23, 2026
1 check passed
@pgundlach pgundlach deleted the claude/cover-error-paths branch June 23, 2026 10:06
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.

2 participants