tests/testthat/test-validate.R

test_that(".validate_df rejects non-data-frame input", {
  expect_error(.validate_df("not a df"), "must be a data frame")
})

test_that(".validate_df rejects empty data frame", {
  expect_error(.validate_df(data.frame()), "has 0 rows")
})

test_that(".validate_df checks column existence", {
  df <- data.frame(a = 1, b = 2)
  expect_error(.validate_df(df, "a", "c"), "not found")
  expect_silent(.validate_df(df, "a", "b"))
})

Try the Rbearcat package in your browser

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

Rbearcat documentation built on March 21, 2026, 5:07 p.m.