tests/testthat/test-get-weights.R

test_that("returns weights as expected", {
  DAT_min <- c(-100, 10, 100, 200)
  DAT_max <- c(-100, 11, 110, 300)
  results <- c(1, 1, 0.1, 0.01)

  expect_equal(get.weights(DAT_min = DAT_min,
                           DAT_max = DAT_max,
                           verbose = FALSE),
               results)
})

test_that("returns message for same values", {
  DAT_min <- c(1)
  DAT_max <- c(1)
  results <- c(1)

  expect_message(get.weights(DAT_min = DAT_min,
                             DAT_max = DAT_max,
                             verbose = TRUE),
                 "same value")
})

test_that("fails for nun-numeric values", {
  DAT_min <- c("1")
  DAT_max <- c("1")

  expect_error(get.weights(DAT_min = DAT_min,
                           DAT_max = DAT_max),
                 "numeric")
})

Try the datplot package in your browser

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

datplot documentation built on Nov. 19, 2023, 1:09 a.m.