File: test-base.R

package info (click to toggle)
r-cran-assertthat 0.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 220 kB
  • sloc: sh: 9; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
context("Base assertions")

test_that("any message is useful", {
  expect_equal(validate_that(any(TRUE, FALSE)), TRUE)
  
  x <- c(FALSE, FALSE)
  expect_equal(validate_that(any(x)), "No elements of x are true")
})

test_that("all message is useful", {
  expect_equal(validate_that(all(TRUE, TRUE)), TRUE)
  
  x <- c(FALSE, TRUE)
  expect_match(validate_that(all(x)), "Elements .* of x are not true")
})

test_that("custom message is printed", {
  expect_equal(validate_that(FALSE, msg = "Custom message"), "Custom message")
})