tests/testthat/test_rangeVal.R

context("rangeVal")

test_that("rangeVal", {
  expect_equal(rangeVal(c(1, 5)), 4)
  expect_equal(rangeVal(1), 0)
  expect_equal(rangeVal(1:3), 2)
  
  # NAs
  expect_equal(rangeVal(c(1, 2, NA)), NA_real_)
  expect_equal(rangeVal(c(1, 2, NA), na.rm = TRUE), 1)
  expect_equal(rangeVal(c(NA_real_), na.rm = TRUE), NA_real_)
})

Try the BBmisc package in your browser

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

BBmisc documentation built on Sept. 29, 2022, 5:12 p.m.