tests: add edge-case tests for str_pad()#611
Closed
LeonidasZhak wants to merge 1 commit into
Closed
Conversation
Add 12 new test blocks covering common data cleaning scenarios: - NA handling (single NA, mixed vector, all sides) - Empty string and empty character(0) input - Custom pad characters (0, -, ., *) - Width of 0 (no padding) - Width equal to string width (no padding needed) - Width less than string width (unchanged) - Vectorised width parameter - Vectorised pad parameter - Names preservation for all sides (left, right, both) - Input validation (invalid side, invalid use_width type) Total: 33 new test expectations (9 existing + 33 new = 42 total).
Author
|
Withdrawing this small automated PR while I consolidate an oversized batch of contributions and reduce maintainer review burden. Sorry for the noise, and thank you for maintaining the project. |
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.
Summary
Adds edge-case tests for
str_pad()covering common data cleaning scenarios that had limited test coverage.Rationale
str_pad()is a key text formatting function used in data cleaning pipelines (e.g., padding IDs to fixed width, formatting numeric codes, aligning text for display). The existing test file (45 lines, 9 expectations) only covered:Missing coverage for common data cleaning scenarios:
Tests Added (12 test blocks, 33 new expectations)
str_pad() handles NA values— Single NA, mixed NA/vector, NA with right/both sidesstr_pad() handles empty strings— Empty string with all sides, width 0, width 1str_pad() handles empty character(0)— Empty vector with left and right sidesstr_pad() respects custom pad character— 0, -, ., * with all sidesstr_pad() handles width of 0— No padding appliedstr_pad() does not pad when width equals string width— All sidesstr_pad() does not pad when width is less than string width— Width 3, 1, 0str_pad() vectorises width— Left and right sidesstr_pad() vectorises pad— Left and right sidesstr_pad() preserves names for all sides— Left, right, bothstr_pad() validates inputs— Invalid side, invalid use_width typeValidation
Rscript -e 'devtools::test(filter = "pad")'— 0 failures, 42 passes (9 existing + 33 new)test-sub.R(unrelated), all other tests pass