-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Summary
The parse_update_entry function in src/util/mod.rs parses update lines but could benefit from more comprehensive tests covering edge cases. Add tests for malformed input, package names with dashes, empty/whitespace input, and Unicode characters.
Files to modify
src/util/mod.rs(add test cases in the#[cfg(test)]module)
Expected behavior
The test suite should cover:
- Valid inputs: Standard pacman update format parsing
- Malformed inputs: Missing arrows, malformed versions, incomplete entries
- Edge cases: Package names with dashes, empty/whitespace input, Unicode characters
- Error handling: Proper
Nonereturns for invalid formats
Implementation approach
Add a new test function util_parse_update_entry with comprehensive test cases:
Testing
-
cargo checkpasses -
cargo clippy --all-targets --all-features -- -D warningspasses -
cargo test -- --test-threads=1passes - Test valid parsing of standard pacman update format
- Test malformed inputs return
None - Test package names containing dashes are handled correctly
- Test empty and whitespace-only inputs return
None - Test Unicode characters in package names
- Test version numbers with various formats (numbers, letters, dashes)
- Test edge cases with extra whitespace around separators
Additional context
The parse_update_entry function parses lines in the format:
"name - old_version -> name - new_version"
Key parsing logic:
- Uses
find(" -> ")to locate the arrow separator - Uses
rfind(" - ")to find the last dash before the arrow (handles package names with dashes) - Returns
Nonefor any malformed input
Test cases should cover real-world pacman output scenarios and ensure the function is robust against various input formats and edge cases that might occur in practice.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed