tests/testthat/test-check_args.R

# library(testthat); library(downsize)
context("check_args")

test_that("Function check_args() runs correctly", {
  data(mtcars)
  for(r in c(T, F)) for(d in c(T, F)){
    args = list(big = rbind(mtcars, mtcars), small = mtcars, random = r, downsize = d)
    expect_error(check_args(args))
    args$warn = T
    expect_silent(check_args(args))
    x = args
    x$random = NULL
    expect_error(check_args(x))
    x$random = "random"
    expect_error(check_args(x))
    expect_error(check_args(list(big = 10)))
  }
})

Try the downsize package in your browser

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

downsize documentation built on March 31, 2023, 10:41 p.m.