tests/testthat/test-cc.R

context("cc functions")

# remove non-ASCII
cc_lkp <- cc_lookup[!grepl("[^ -~]", names(cc_lookup))]

cc <- data.frame(country = names(cc_lkp),
                 region  = cc_lkp,
                 stringsAsFactors = FALSE)

test_that("get_cc", {
  expect_equal(get_cc(cc$country), cc$region)
  expect_equal(get_cc(tolower(cc$country)), cc$region)
  expect_equal(get_cc("BLAH"), NA_character_)
})

test_that("check_cc", {
  expect_equal(check_cc(cc$region), rep(TRUE, nrow(cc)))
  expect_equal(check_cc("BLAH"), FALSE)
})

test_that("validate_cc", {
  expect_equal(dialr:::validate_cc(cc$region), NULL)
  expect_error(dialr:::validate_cc("BLAH"))
})

Try the dialr package in your browser

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

dialr documentation built on Oct. 17, 2023, 1:11 a.m.