Skip to content

[Routine - MIGAO] Add unit test coverage for PinyinDict TSV parsing - #38

Draft
winterdrive wants to merge 1 commit into
mainfrom
routine/migao-fix-pinyin-dict-test-coverage-260820
Draft

[Routine - MIGAO] Add unit test coverage for PinyinDict TSV parsing#38
winterdrive wants to merge 1 commit into
mainfrom
routine/migao-fix-pinyin-dict-test-coverage-260820

Conversation

@winterdrive

Copy link
Copy Markdown
Owner

Pre-flight Check

Changes

src/pinyin_dict.rs had zero test coverage. Extracted the inline TSV-parsing loop in PinyinDict::load() into a standalone parse_tsv_into() function (mirroring the existing pattern already used in src/dict.rs), and added unit tests covering:

  • blank lines and # comment lines are skipped
  • malformed rows (wrong tab-field count) are skipped
  • an unparseable frequency column falls back to 1
  • multiple entries under the same pinyin key accumulate correctly
  • global() loads a non-empty dict from the embedded data/pinyin.tsv

This PR does not modify core dictionary data (data/bopomofo.tsv or any embedded RIME resources), does not add/remove/update any Cargo.toml dependencies, and does not touch package version metadata.

Safety Verification

Run locally on this branch, all passed:

  • cargo check --all-targets — passed
  • cargo clippy --all-targets -- -D warnings — passed, no warnings
  • cargo test — 101 passed (up from 96), 0 failed, in the migao lib test binary; migao-watch bin tests (6) and doc-tests unaffected
  • cargo fmt --check — passed, no diff

CI / Release Gate Note

This is a daily routine Draft PR. Package version bump (Cargo.toml/Cargo.lock) and CHANGELOG.md consolidation are intentionally deferred to the weekend release/integration PR.

Extracts the inline parsing loop in PinyinDict::load() into a standalone
parse_tsv_into() function (mirroring the existing pattern in dict.rs) and
covers it with tests for blank/comment lines, malformed rows, unparseable
frequency fallback, and multi-entry accumulation. pinyin_dict.rs previously
had zero test coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

routine Daily automated maintenance PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant