Skip to content

Commit

Permalink
Add snapshot tests to verify informative error messages in step_cut()
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwinget committed Aug 15, 2024
1 parent 7e6d258 commit 507c413
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test-cut.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ test_that("tidy method works", {
)
})

test_that("step_cut() provides informative error on missing values", {
# Single missing value
mtcars_with_na <- mtcars
mtcars_with_na[1, "mpg"] <- NA

expect_warning(
recipe(~ ., data = mtcars_with_na) %>%
step_cut(mpg, breaks = 20) %>%
prep()
)

# Multiple missing values
mtcars_with_nas <- mtcars
mtcars_with_nas[c(1, 3, 5), "mpg"] <- NA

expect_warning(
recipe(~ ., data = mtcars_with_nas) %>%
step_cut(mpg, breaks = 20) %>%
prep()
)
})


# Infrastructure ---------------------------------------------------------------

Expand Down

0 comments on commit 507c413

Please sign in to comment.