Skip to content

Commit

Permalink
Use expect_null() where appropriate in tests (#6211)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored May 24, 2022
1 parent 6259a40 commit 778ec9b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/test-count-tally.r
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test_that("output preserves class & attributes where possible", {
expect_s3_class(out, "grouped_df")
expect_equal(group_vars(out), "g")
# summarise() currently drops attributes
expect_equal(attr(out, "my_attr"), NULL)
expect_null(attr(out, "my_attr"))
})

test_that("works with dbplyr", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-nth-value.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ test_that("nth works with lists", {
x <- list(1, 2, 3)

expect_equal(nth(x, 1), 1)
expect_equal(nth(x, 4), NULL)
expect_null(nth(x, 4))
expect_equal(nth(x, 4, default = 1), 1)
})

Expand All @@ -24,7 +24,7 @@ test_that("first uses default value for 0 length vectors", {
expect_equal(first(integer()), NA_integer_)
expect_equal(first(numeric()), NA_real_)
expect_equal(first(character()), NA_character_)
expect_equal(first(list()), NULL)
expect_null(first(list()))
})

test_that("firsts uses default value for 0 length augmented vectors", {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-summarise.r
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ test_that("preserved class, but not attributes", {

out <- df %>% summarise(n = n())
expect_s3_class(out, "data.frame", exact = TRUE)
expect_equal(attr(out, "res"), NULL)
expect_null(attr(out, "res"))

out <- df %>% group_by(g1) %>% summarise(n = n())
# expect_s3_class(out, "data.frame", exact = TRUE)
expect_equal(attr(out, "res"), NULL)
expect_null(attr(out, "res"))
})

test_that("works with unquoted values", {
Expand Down

0 comments on commit 778ec9b

Please sign in to comment.