tests/testthat/test-nuts_get_missing.R

# Run error tests
#---------------------
test_that("data input not valid", {
  expect_error(
    nuts_get_missing(
      data = 1
    ),
    "Input `data` must be a nuts.classified-object, not a number."
  )
})

# Run positive tests
test_that("Classify returns nuts.classified", {
  expect_equal(attr(
    nuts_classify(data = manure_2_indic_DE_2003(),
                  nuts_code = "geo") %>%
      nuts_get_missing(),
    "class"
  ),
  c("tbl_df", "tbl", "data.frame"))
})

test_that("Dimensions of ouput", {
  expect_equal(dim(
    nuts_classify(data = manure_2_indic_DE_2003(),
                  nuts_code = "geo") %>%
      nuts_get_missing()
  ),
  c(4, 4))
})

Try the nuts package in your browser

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

nuts documentation built on Sept. 11, 2024, 6:05 p.m.