Cover text decoding; consolidate text tests into text_test.go#16
Merged
Conversation
Add UTF-16 LE/BE round-trips through decodeTextString (a surrogate-pair emoji exercises the hard path), odd-length no-panic checks for both byte orders, PDFDocEncoding table spot-checks including undefined slots, and parseDate cases verified against independently built time.Time values. Move the three text tests that lived in reader_test.go (UTF-16BE, PDFDocEncoding, parseDate) here, superseding them. Simplify the /D: prefix strip to strings.TrimPrefix. text.go decodeTextString/decodeUTF16BE/decodePDFDocEncoding to 100%, decodeUTF16LE 0% -> 100%, parseDate to 98%.
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.
Raises
text.gocoverage and moves the misplaced text tests to their proper home.Tests (independent oracles, not characterization)
TestDecodeTextStringUTF16RoundTrip— round-trips viautf16.Encode; the😀forces a surrogate pair, and both byte orders dispatch off their BOM.TestDecodeUTF16OddLengthNoPanic— a dangling odd byte is dropped (BE and LE), no out-of-range read.TestDecodeTextStringDispatch— UTF-8 BOM (PDF 2.0) and PDFDocEncoding default.TestDecodePDFDocEncoding— table spot-checks (breve, bullet, euro, Latin-1é) incl. undefined slots → U+FFFD.TestParseDate— valid/leap/year-only/no-prefix/malformed/month-13/tz-offset, each checked against an independently constructedtime.Time.Cleanup
reader_test.go(TestTextDecodingUTF16BE,TestTextDecodingPDFDocEncoding,TestParseDate) are superseded and moved here, matching thetext.go→text_test.goconvention.parseDate's/D:strip simplified tostrings.TrimPrefix(staticcheck S1017).parseDate's leniency (e.g.hour=99rolls over viatime.Date) is left as-is — best-effort date parsing, not a crash; the tests cover valid input and reject clearly-malformed dates rather than enshrining the rollover.Coverage:
decodeTextString/decodeUTF16BE/decodePDFDocEncoding→ 100%;decodeUTF16LE0% → 100%;parseDate→ 98%.