R/checkTRUE.R

Defines functions checkTRUE

Documented in checkTRUE

#' Check if an argument is TRUE
#'
#' @description
#' Simply checks if an argument is \code{TRUE}.
#'
#' @templateVar fn TRUE.
#' @template x
#' @template na.ok
#' @template checker
#' @export
#' @examples
#' testTRUE(TRUE)
#' testTRUE(FALSE)
checkTRUE = function(x, na.ok = FALSE) {
  qassert(na.ok, "B1")
  if (isTRUE(x) || (na.ok && length(x) == 1L && is.na(x)))
    return(TRUE)
  return("Must be TRUE")
}

#' @export
#' @rdname checkTRUE
check_true = checkTRUE

#' @export
#' @include makeAssertion.R
#' @template assert
#' @rdname checkTRUE
assertTRUE = makeAssertionFunction(checkTRUE, use.namespace = FALSE)

#' @export
#' @rdname checkTRUE
assert_true = assertTRUE

#' @export
#' @include makeTest.R
#' @rdname checkTRUE
testTRUE = makeTestFunction(checkTRUE)

#' @export
#' @rdname checkTRUE
test_true = testTRUE

Try the checkmate package in your browser

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

checkmate documentation built on May 29, 2024, 4:08 a.m.