| expect_that {testthat} | R Documentation |
An expectation checks whether a single condition holds true. testthat currently provides the following expectations. See their documentation for more details
expect_that(object, condition, info = NULL, label = NULL)
object |
object to test |
condition, |
a function that returns whether or not the condition is met, and if not, an error message to display. |
label |
object label. When |
info |
extra information to be included in the message (useful when writing tests in loops). |
is_true: truth
is_false: falsehood
is_a: inheritance
equals: equality with numerical tolerance
is_equivalent_to: equality ignoring
attributes
is_identical_to: exact
identity
matches: string matching
prints_text: output matching
throws_error: error matching
gives_warning: warning matching
shows_message: message matching
takes_less_than: performance
Expectations are arranged into tests with
test_that and tests are arranged into
contexts with context.
expect_that(5 * 2, equals(10)) expect_that(sqrt(2) ^ 2, equals(2)) ## Not run: expect_that(sqrt(2) ^ 2, is_identical_to(2)) ## End(Not run)