tests/testthat/test-lgl.R

context("check-lgl")

test_that("check_lgl errors", {
  y <- TRUE
  expect_identical(check_lgl(y), y)
  y <- 2
  expect_error(check_lgl(y), "y must be class logical")
  y <- c(TRUE, TRUE)
  expect_error(check_lgl(y), "y must have 1 element")
  y <- NA
  expect_error(check_lgl(y), "y must not include missing values")
  expect_identical(check_lgl(FALSE), FALSE)
})

test_that("check_flag errors", {
  y <- TRUE
  expect_identical(check_flag(y), y)
  y <- 2
  expect_error(check_flag(y), "y must be class logical")
  y <- c(TRUE, TRUE)
  expect_error(check_flag(y), "y must have 1 element")
  y <- NA
  expect_error(check_flag(y), "y must not include missing values")
  expect_identical(check_flag(FALSE), FALSE)
})

Try the checkr package in your browser

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

checkr documentation built on May 1, 2019, 6:59 p.m.