Skip to content

Commit

Permalink
test(gradethis_equal.list): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rossellhayes committed Jun 2, 2023
1 parent ce38fcf commit 55d11d8
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/testthat/test-gradethis_equal.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ test_that("gradethis_equal.list() checks names", {
expect_false(gradethis_equal(list(pi, letters), list(a = pi, b = letters)))
})

test_that("gradethis_equal() distinguishes lists from vectors", {
expect_false(gradethis_equal(as.list(letters), letters))
expect_false(gradethis_equal(letters, as.list(letters)))
expect_false(gradethis_equal(list(as.list(letters)), list(letters)))
expect_false(gradethis_equal(list(letters), list(as.list(letters))))
test_that("gradethis_equal.list() is only used when x and y are both bare lists", {
example_list <- list(1, 2, 3)
example_vector <- c(1, 2, 3)

expect_false(gradethis_equal(example_list, example_vector))
expect_false(gradethis_equal(example_vector, example_list))
expect_false(gradethis_equal(list(example_list), list(example_vector)))
expect_false(gradethis_equal(list(example_vector), list(example_list)))

example_list <- list(a = 1, b = 2)
example_data_frame <- data.frame(a = 1, b = 2)

expect_false(gradethis_equal(example_list, example_data_frame))
expect_false(gradethis_equal(example_data_frame, example_list))
expect_false(gradethis_equal(list(example_list), list(example_data_frame)))
expect_false(gradethis_equal(list(example_data_frame), list(example_list)))
})

test_that("gradethis_equal uses methods from ggcheck", {
Expand Down

0 comments on commit 55d11d8

Please sign in to comment.