File: test-assert-that.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 (16 lines) | stat: -rw-r--r-- 565 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
context("assert_that")

test_that("assert_that handles long false assertions gracefully", {
    expect_error(
        assert_that(isTRUE(10 + sqrt(25) + sum(1:10) + sqrt(25) + sum(11:20) + sqrt(25) + sum(21:30) + sqrt(25) + sum(31:40) + sqrt(25) + sum(41:50))),
        "^isTRUE\\(.* [.]{3} is not TRUE$"
    )
})

test_that("assert_that handles has_name failures with multiple missing names", {
    x <- list(a = TRUE, b = "hello")
    expect_error(
        assert_that(has_name(x, c("a", "f", "g"))),
        regexp = "x does not have all of these name"
    )
})