Skip to content

[Repo Assist] test: add 11 unit tests for word_wrap in ui.rs#166

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/test-word-wrap-2026-04-29-ec1ef0dbcfb75f00
Draft

[Repo Assist] test: add 11 unit tests for word_wrap in ui.rs#166
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/test-word-wrap-2026-04-29-ec1ef0dbcfb75f00

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

What

Adds 11 targeted unit tests to src/ui.rs for the word_wrap function, which previously had zero test coverage despite being a non-trivial algorithm used to wrap package descriptions in the detail panel.

Why

word_wrap handles several distinct code paths:

  • Word-boundary wrapping when a line exceeds max_width
  • Mid-word force-break when a single token is wider than max_width
  • Multi-paragraph text (newline-separated)
  • Unicode/CJK double-width character handling
  • The special case where max_width == 0

None of these were exercised by any test.

Tests added

Test Covers
word_wrap_empty_string_returns_one_empty_line empty input → [""]
word_wrap_single_word_within_limit no-wrap fast path
word_wrap_single_line_fits_exactly boundary: line width == max
word_wrap_wraps_at_word_boundary 2-word wrap
word_wrap_three_words_wrap_correctly multi-word wrap
word_wrap_zero_max_returns_text_as_single_line max_width == 0 branch
word_wrap_long_word_force_breaks force-break closure
word_wrap_very_long_word_splits_into_multiple_lines multi-chunk force-break
word_wrap_preserves_paragraph_breaks newline-delimited paragraphs
word_wrap_each_line_is_within_max_width round-trip integrity check
word_wrap_cjk_respects_display_width CJK 2-column-wide chars

Test Status

cargo test     ✅  242 passed (was 231)
cargo fmt      ✅  no formatting issues
cargo clippy   ✅  no warnings

Generated by Repo Assist · ● 1.7M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

word_wrap is a non-trivial algorithm (word-boundary wrapping with
mid-word force-break for overlong tokens, multi-paragraph handling,
and CJK display-width awareness) that had zero test coverage.

New tests cover:
- empty string → single empty line
- single word within/at limit
- multi-word line that fits exactly
- word-boundary wrap
- three-word wrap
- zero max_width special case
- single long word force-break
- very long word split into multiple lines
- multi-paragraph preservation
- round-trip word integrity at max=15
- CJK double-width character wrapping

231 → 242 tests passing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants