Skip to content

Commit

Permalink
Snapshot tests for vec_rank(NULL)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Mar 7, 2024
1 parent 255e9b4 commit 4ce3312
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/rank.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# `x` must not be `NULL` (#1823)

Code
vec_rank(NULL)
Condition
Error:
! This type is not supported by `vec_order()`.

---

Code
vec_rank(NULL, incomplete = "na")
Condition
Error:
! This type is not supported by `vec_order()`.

# `ties` is validated

Code
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-rank.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ test_that("`x` must be a vector", {
expect_error(vec_rank(identity), class = "vctrs_error_scalar_type")
})

test_that("`x` must not be `NULL` (#1823)", {
expect_snapshot(error = TRUE, {
vec_rank(NULL)
})
expect_snapshot(error = TRUE, {
vec_rank(NULL, incomplete = "na")
})
})

test_that("`ties` is validated", {
expect_snapshot(error = TRUE, vec_rank(1, ties = "foo"))
expect_snapshot(error = TRUE, vec_rank(1, ties = 1))
Expand Down

0 comments on commit 4ce3312

Please sign in to comment.