Learn R Programming

tinytest (version 0.9.4)

expect_equal: Express expectations

Description

Express expectations

Usage

expect_equal(current, target, tol = sqrt(.Machine$double.eps), ...)

expect_identical(current, target)

expect_equivalent(current, target, tol = sqrt(.Machine$double.eps), ...)

expect_true(current)

expect_false(current)

expect_error(current, pattern = ".*")

expect_warning(current, pattern = ".*")

Arguments

current

[R object or expression] Outcome or expression under scrutiny.

target

[R object or expression] Expected outcome

tol

[numeric] Test equality to machine rounding. Passed to all.equal (tolerance)

...

Passed to all.equal

pattern

[character] A regular expression to match the message.

Value

A tinytest object. A tinytest object is a logical with attributes holding information about the test that was run

Details

expect_equivalent calls expect_equal with the extra arguments check.attributes=FALSE and use.names=FALSE

See Also

Other test-functions: ignore

Examples

Run this code
# NOT RUN {
expect_equal(1 + 1, 2)       # TRUE
expect_equal(1 - 1, 2)       # FALSE
expect_equivalent(2, c(x=2)) # TRUE
expect_equal(2, c(x=2))      # FALSE

# }

Run the code above in your browser using DataLab