Conversation
Reviewer's GuideIntroduces a regression test ensuring wrap_text handles hyphenated words without inserting spaces (built via concat!), and removes an obsolete stray-space assertion. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughAdd a new test to the suite for the Changes
Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/lib.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENTS.md
⚙️ CodeRabbit Configuration File
| #[test] | ||
| fn wrap_text_does_not_insert_spaces_in_hyphenated_words() { | ||
| let input = vec![ | ||
| concat!( | ||
| "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt ", | ||
| "elit-sed fermentum congue. Vivamus dictum nulla sed consectetur ", | ||
| "volutpat." | ||
| ) | ||
| .to_string(), | ||
| ]; | ||
| let wrapped = wrap_text(&input, 80); | ||
| assert_eq!( | ||
| wrapped, | ||
| vec![ | ||
| "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt" | ||
| .to_string(), | ||
| "elit-sed fermentum congue. Vivamus dictum nulla sed consectetur volutpat." | ||
| .to_string(), | ||
| ] | ||
| ); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Deduplicate hyphen-wrap tests via #[rstest] parameterisation
The new test exercises exactly the same invariant as wrap_text_preserves_hyphenated_words, only with a different input string and wrap width. The coding guidelines mandate replacing duplicated tests with #[rstest(...)] parameterised cases. Merge both checks into a single fixture that varies:
- the input string
- the wrap width
- the expected vector
This removes repetition while preserving coverage and keeps the test module concise.
Example skeleton:
-#[test]
-fn wrap_text_preserves_hyphenated_words() { … }
-
-#[test]
-fn wrap_text_does_not_insert_spaces_in_hyphenated_words() { … }
+#[rstest(
+ (input, width, expected),
+ case(
+ "A word that is very-long-word indeed",
+ 20,
+ vec![
+ "A word that is",
+ "very-long-word",
+ "indeed"
+ ]
+ ),
+ case(
+ concat!(
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt ",
+ "elit-sed fermentum congue. Vivamus dictum nulla sed consectetur volutpat."
+ ),
+ 80,
+ vec![
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tincidunt",
+ "elit-sed fermentum congue. Vivamus dictum nulla sed consectetur volutpat."
+ ]
+ )
+)]
+fn wrap_text_preserves_hyphenated_words(input: &str, width: usize, expected: Vec<&str>) {
+ let wrapped = wrap_text(&[input.to_string()], width);
+ assert_eq!(
+ wrapped,
+ expected.into_iter().map(str::to_string).collect::<Vec<_>>()
+ );
+}Enforce cargo fmt and cargo clippy after refactor to keep the build clean.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/lib.rs around lines 762 to 782, the test
wrap_text_does_not_insert_spaces_in_hyphenated_words duplicates the logic of
wrap_text_preserves_hyphenated_words with different inputs. Refactor by merging
both tests into a single parameterized test using #[rstest] that takes input
string, wrap width, and expected output vector as parameters. This will remove
duplication while maintaining test coverage. After refactoring, run cargo fmt
and cargo clippy to ensure code style and linting compliance.
Summary
concat!Testing
make fmtmake lintmake testhttps://chatgpt.com/codex/tasks/task_e_6875fac6b5608322a057d88ff845287f
Summary by Sourcery
Add a regression test to ensure wrap_text does not insert spaces in hyphenated words when wrapping.
Enhancements:
Tests:
Chores: