tests/testthat/test-helpers-where.R
raw| 1 | test_that("where() selects with a predicate", { |
| 2 | expect_identical(select_loc(iris, where(is.factor)), c(Species = 5L)) |
| 3 | expect_identical(select_loc(iris, where(~ is.factor(.x))), c(Species = 5L)) |
| 4 | }) |
| 5 | |
| 6 | test_that("where() checks return values", { |
| 7 | expect_snapshot(error = TRUE, { |
| 8 | where(NA) |
| 9 | }) |
| 10 | |
| 11 | expect_snapshot(error = TRUE, { |
| 12 | select_loc(iris, where(~NA)) |
| 13 | select_loc(iris, where(~1)) |
| 14 | select_loc(iris, where(mean)) |
| 15 | }) |
| 16 | }) |