is_identical_to {testthat}R Documentation

Expectation: is the object identical to another?

Description

Comparison performed using identical.

Usage

  is_identical_to(expected, label = NULL)

  expect_identical(object, expected, info = NULL,
    label = NULL, expected.label = NULL)

Arguments

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 NULL, computed from deparsed object.

object

object to test

info

extra information to be included in the message (useful when writing tests in loops).

expected.label

Equivalent of label for shortcut form.

See Also

Other expectations: equals, expect_equal, expect_equivalent, expect_error, expect_false, expect_is, expect_match, expect_message, expect_output, expect_true, expect_warning, gives_warning, is_a, is_equivalent_to, is_false, is_true, matches, prints_text, shows_message, takes_less_than, throws_error

Examples

a <- letters[1:3]
expect_that(a, is_identical_to(c("a", "b", "c")))
expect_identical(a, c("a", "b", "c"))

# Identical does not take into account numeric tolerance
## Not run: 
expect_that(sqrt(2) ^ 2, is_identical_to(2))
expect_identical(sqrt(2) ^ 2, 2)

## End(Not run)

[Package testthat version 0.6 Index]