tests/testthat/test-abcd_demo.R

test_that("hasn't changed", {
  on_windows <- identical(.Platform$OS.type, "windows")
  skip_if(on_windows)

  r_version <- paste0(
    R.version$major,
    ".",
    R.version$minor
  )
  r_version > "3.6.0"
  # abcd_demo is now generated using random sampling.
  # random sampling seems to have changed in R after version 3.6.0
  # see ?RNGkind
  skip_if(r_version < "3.6.0")

  expect_snapshot_value(ceiling_dbl(abcd_demo), style = "json2")
})

test_that("abcd_demo has column `company_id`", {
  expect_true(hasName(abcd_demo, "company_id"))
})

test_that("abcd_demo$company_id is of type character, as promised", {
  expect_type(abcd_demo$company_id, "character")
})

# this is currently undesirable: a single unique company should be able to have
# data in multiple sectors
# test_that("abcd_demo$company_id is unique to `name_company` and `sector`", {
#   out <- abcd_demo[c("company_id", "name_company", "sector")]
#   out <- unique(out)
#   out <- out$company_id[duplicated(out$company_id)]
#
#   expect_length(out, 0L)
# })

Try the r2dii.data package in your browser

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

r2dii.data documentation built on Nov. 14, 2023, 1:09 a.m.