tests: add edge-case tests for str_wrap()#610
Closed
LeonidasZhak wants to merge 1 commit into
Closed
Conversation
Add tests covering: - NA value preservation (single NA, mixed NA/vector, NA in middle) - Empty string and empty character vector handling - Vector input processing - indent parameter (first line indentation) - exdent parameter (subsequent line indentation) - Single word longer than width (no wrapping) - Multiple whitespace collapsing - Input validation (width, indent, exdent, whitespace_only)
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_wrap()covering common data cleaning scenarios that had limited test coverage.Changes
File:
tests/testthat/test-wrap.R(+51 lines)Tests Added (8 test blocks)
str_wrap() handles NA values— Verifies NA preservation for single NA, mixed NA/vector, and NA in middle of vectorstr_wrap() handles empty input— Empty string and empty character vectorstr_wrap() works with vector input— Element-wise processing of character vectorsstr_wrap() respects indent parameter— First line indentationstr_wrap() respects exdent parameter— Subsequent line indentationstr_wrap() handles single word longer than width— Word longer than target width is not brokenstr_wrap() collapses multiple whitespace— Leading/trailing/internal whitespace normalizationstr_wrap() validates its inputs— Error on invalid width, indent, exdent, whitespace_onlyMotivation
str_wrap()is a key text formatting function used in data cleaning pipelines (e.g., formatting labels, wrapping long strings). The existing tests (23 lines) only covered basic wrapping, whitespace-only mode, and name preservation. These additions cover common edge cases encountered when processing real-world text data.Testing
devtools::test(filter = "wrap"): 0 failures, 20 passes (4 existing + 16 new)