expect_true(2 == 2)
# Failed expectations will throw an error
show_failure(expect_true(2 != 2))
# where possible, use more specific expectations, to get more informative
# error messages
a <- 1:4
show_failure(expect_true(length(a) == 3))
show_failure(expect_equal(length(a), 3))
x <- c(TRUE, TRUE, FALSE, TRUE)
show_failure(expect_true(all(x)))
show_failure(expect_all_true(x))
Run the code above in your browser using DataLab