Learn R Programming

testthat (version 0.2)

equals: Expectation: is the object equal (with numerical tolerance) to a value?

Description

Expectation: is the object equal (with numerical tolerance) to a value?

Usage

equals(expected, ...)

Arguments

expected
expected value
...
other values passed to all.equal

Details

Comparison performed using all.equal.

Examples

Run this code
a <- 10
expect_that(a, equals(10))

# Use equals() when testing for numeric equality
sqrt(2) ^ 2 - 1
expect_that(sqrt(2) ^ 2, equals(2))
# Neither of these forms taken floating point representation errors into
# account
expect_that(sqrt(2) ^ 2 == 2, is_true())
expect_that(sqrt(2) ^ 2, is_identical_to(2))

Run the code above in your browser using DataLab