Learn R Programming

testthat (version 0.2)

is_true: Expectation: is the object true?

Description

Expectation: is the object true?

Arguments

Details

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.

See Also

is_false for complement

Examples

Run this code
expect_that(2 == 2, is_true())
# Failed expectations will throw an error
expect_that(2 != 2, is_true())
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))

Run the code above in your browser using DataLab