tests/testthat/test-method-grim-sequence.R

ranking <- seq_distance_df("5.37", n = 40) %>%
  grim_map() %>%
  seq_test_ranking() %>%
  suppressMessages()


test_that("The function returns a tibble", {
  ranking %>% expect_s3_class("tbl_df")
})

test_that("Dimensions are correct", {
  ranking$inconsistent[5:6] %>% is.na() %>% all() %>% expect_true()
  ranking$lead_lag[5:6]     %>% is.na() %>% all() %>% expect_true()
})

test_that("Values are correct", {
  ranking$consistent        %>% expect_equal(c(1, 2, 4, 6, 7, 9))
  ranking$inconsistent[1:4] %>% expect_equal(c(3, 5, 8, 10))
  ranking$lead_lag[1:4]     %>% expect_equal(c(2, 3, 4, 4))
})

Try the scrutiny package in your browser

Any scripts or data that you put into this service are public.

scrutiny documentation built on Sept. 22, 2024, 9:06 a.m.