tests/testthat/test_adds.R

hpc <- hpc_data[1:150, c(2:5, 8)]

# ------------------------------------------------------------------------------

test_that('adding row indicies', {
  hpc_2 <- hpc %>% add_rowindex()
  expect_true(nrow(hpc_2) == 150)
  expect_true(sum(names(hpc_2) == ".row") == 1)
  expect_true(is.integer(hpc_2$.row))

  mtcar_2 <- dplyr::as_tibble(mtcars) %>% dplyr::slice(0) %>% add_rowindex()
  expect_true(nrow(mtcar_2) == 0)
  expect_true(sum(names(mtcar_2) == ".row") == 1)
  expect_true(is.integer(mtcar_2$.row))

  expect_error(as.matrix(mtcars) %>% add_rowindex())
})

Try the parsnip package in your browser

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

parsnip documentation built on Aug. 18, 2023, 1:07 a.m.