Skip to content

Commit

Permalink
add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Feb 6, 2024
1 parent 684df79 commit 3869b37
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/testthat/test-data_modify.R
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ test_that("data_modify .if/.at arguments", {
data_modify(d, .at = c("Species", "Hi", "Test"), .modify = as.numeric),
regex = "Variables \"Hi\" and \"Test\""
)
expect_error(
data_modify(d, .modify = as.numeric),
regex = "You need to specify"
)
expect_error(
data_modify(d, .at = "Species", .modify = function(x) 2 / y + x),
regex = "Error in modifying variable"
Expand All @@ -529,6 +533,10 @@ test_that("data_modify .if/.at arguments", {
data_modify(d, .at = "Species", .modify = function(x) 2 * x),
regex = "Error in modifying variable"
)
expect_error(
data_modify(d, .at = "Species", .if = is.factor),
regex = "You need to specify"
)
# newly created variables are not modified by if/at
out <- data_modify(d, new_length = Petal.Length * 2, .if = is.numeric, .modify = as.factor)
expect_identical(out$new_length, c(2.8, 2.8, 2.6, 3, 2.8))
Expand Down

0 comments on commit 3869b37

Please sign in to comment.