tests/testthat/test_calculate_rse.R

context("calculate_rse() tests")

test_that("calculate_rse() errors with x == NULL", {
  
  x <- NULL
  
  expect_error(calculate_rse(x))
  
  })

test_that("calculate_rse() errors when length(x) < 2)", {
  
  x <- rnorm(1)
  
  expect_error(calculate_rse(x))
  
})

test_that("calculate_rse() returns appropriate output", {
  
  x <- c(2, 4)
  
  expected <- ((sd(x))/sqrt(length(x)))/mean(x)

  expect_equal(calculate_rse(x), expected)
  
})

Try the AnglerCreelSurveySimulation package in your browser

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

AnglerCreelSurveySimulation documentation built on May 2, 2019, 7:08 a.m.