tests/testthat/test-basic.R

library(samplePackage)

context("fars_summarize_years function")
test_that("summary generated is equal to reference values", {
  expect_equal_to_reference(fars_summarize_years(2013), "far_summarise_years_reference.rds")
})

test_that("Invalid year argument return error", {
  expect_error(suppressWarnings(fars_summarize_years(2016)))
})

context("fars_map_state function")
test_that("Correct map plotting return the expected value", {
  expect_null(fars_map_state(23, 2013))
})

test_that("Incorrect map arguments return error", {
  expect_error(fars_map_state(23, 2016))
  expect_error(fars_map_state(58, 2013), "invalid state number", ignore.case = TRUE)
})
fernandovmacedo/samplePackage documentation built on May 14, 2017, 1:14 a.m.