| is_true {testthat} | R Documentation |
This is a fall-back expectation that you can use when none of the other more specific expectations apply. The disadvantage is that you may get a less informative error message.
is_true() expect_true(object, info = NULL, label = NULL)
object |
object to test |
info |
extra information to be included in the message (useful when writing tests in loops). |
label |
object label. When |
is_false for complement
Other expectations: equals,
expect_equal,
expect_equivalent,
expect_error, expect_false,
expect_identical, expect_is,
expect_match, expect_message,
expect_output,
expect_warning,
gives_warning, is_a,
is_equivalent_to, is_false,
is_identical_to, matches,
prints_text, shows_message,
takes_less_than, throws_error
expect_that(2 == 2, is_true()) expect_true(2 == 2) # Failed expectations will throw an error ## Not run: expect_that(2 != 2, is_true()) ## End(Not run) expect_that(!(2 != 2), is_true()) # or better: expect_that(2 != 2, is_false()) a <- 1:3 expect_that(length(a) == 3, is_true()) # but better to use more specific expectation, if available expect_that(length(a), equals(3))