equals_reference {testthat}R Documentation

Expectation: is the object equal to a reference value stored in a file?

Description

This expectation is equivalent to equals, except that the expected value is stored in an RDS file instead of being specified literally. This can be helpful when the value is necessarily complex. If the file does not exist then it will be created using the value of the specified object, and subsequent tests will check for consistency against that generated value. The test can be reset by deleting the RDS file.

Usage

equals_reference(file, label = NULL, ...)

expect_equal_to_reference(object, file, ..., info = NULL, label = NULL,
  expected.label = NULL)

Arguments

file

The file name used to store the object. Should have an "rds" extension.

label

For the full form, a label for the expected object, which is used in error messages. Useful to override the default (which is based on the file name), when doing tests in a loop. For the short-cut form, the object label, which is computed from the deparsed object by default.

...

other values passed to equals

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-compare, expect_less_than, expect_more_than, is_less_than, is_more_than; expect_equivalent, is_equivalent_to; expect_error, throws_error; expect_false, expect_true, is_false, is_true; expect_identical, is_identical_to; expect_is, is_a; expect_match, matches; expect_message, shows_message; expect_named, has_names; expect_null, is_null; expect_output, prints_text; expect_warning, gives_warning; takes_less_than

Examples

## Not run: 
expect_equal_to_reference(1, "one.rds")

## End(Not run)

[Package testthat version 0.9.1 Index]