-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add sep argument to str_dup #564
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f555ba4
add sep argument to str_dup
edward-burn 6c40b75
update news
edward-burn 342508d
news
edward-burn a4b45b8
magrittr pipe
edward-burn efefb58
updates after review
edward-burn 1834be3
size of times
edward-burn bea5ed3
Merge commit 'b3d6b8f9501451a284d32422716dd364454f548d'
hadley b95ee12
Polish implementation a little
hadley b4e5e3a
Polish tests
hadley 9152c71
Merge commit 'c9aa8cecaed89ac8034b79a7f640c7850719f28c'
hadley 244376b
Use same sep
hadley 089abea
Add example & use `[[`
hadley 7d802a1
Merged origin/main into edward-burn-str_dup_sep
hadley fd9c8b7
Merge branch 'main' into str_dup_sep
hadley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# separator must be a single string | ||
|
||
Code | ||
str_dup("a", 3, sep = 1) | ||
Condition | ||
Error in `str_dup()`: | ||
! `sep` must be a single string or `NULL`, not the number 1. | ||
Code | ||
str_dup("a", 3, sep = c("-", ";")) | ||
Condition | ||
Error in `str_dup()`: | ||
! `sep` must be a single string or `NULL`, not a character vector. | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,21 @@ test_that("0 duplicates equals empty string", { | |
test_that("uses tidyverse recycling rules", { | ||
expect_error(str_dup(1:2, 1:3), class = "vctrs_error_incompatible_size") | ||
}) | ||
|
||
test_that("uses sep argument", { | ||
expect_equal(str_dup("abc", 1, sep = "-"), "abc") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to make it a bit more clear was different in each test by keeping more stuff the same. |
||
expect_equal(str_dup("abc", 2, sep = "-"), "abc-abc") | ||
|
||
expect_equal(str_dup(c("a", "b"), 2, sep = "-"), c("a-a", "b-b")) | ||
expect_equal(str_dup(c("a", "b"), c(1, 2), sep = "-"), c("a", "b-b")) | ||
|
||
expect_equal(str_dup(character(), 1, sep = ":"), character()) | ||
expect_equal(str_dup(character(), 2, sep = ":"), character()) | ||
}) | ||
|
||
test_that("separator must be a single string", { | ||
expect_snapshot(error = TRUE, { | ||
str_dup("a", 3, sep = 1) | ||
str_dup("a", 3, sep = c("-", ";")) | ||
}) | ||
}) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to move the other input check up here so that all the input checks are together.