| equals {testthat} | R Documentation |
Comparison performed using all.equal.
equals(expected, label = NULL, ...)
expect_equal(object, expected, ..., info = NULL,
label = NULL, expected.label = NULL)
expected |
Expected value |
label |
For full form, label of expected object used
in error messages. Useful to override default (deparsed
expected expression) when doing tests in a loop. For
short cut form, object label. When |
expected.label |
Equivalent of |
... |
other values passed to
|
object |
object to test |
info |
extra information to be included in the message (useful when writing tests in loops). |
Other expectations: expect_equivalent,
expect_error, expect_false,
expect_identical, expect_is,
expect_match, expect_message,
expect_output, expect_true,
expect_warning,
gives_warning, is_a,
is_equivalent_to, is_false,
is_identical_to, is_true,
matches, prints_text,
shows_message,
takes_less_than, throws_error
a <- 10 expect_that(a, equals(10)) expect_equal(a, 10) # Use equals() when testing for numeric equality sqrt(2) ^ 2 - 1 expect_that(sqrt(2) ^ 2, equals(2)) expect_equal(sqrt(2) ^ 2, 2) # Neither of these forms take floating point representation errors into # account ## Not run: expect_that(sqrt(2) ^ 2 == 2, is_true()) expect_that(sqrt(2) ^ 2, is_identical_to(2)) ## End(Not run)