class-expectations: Class Expectations

Description Usage Arguments Functions See Also Examples

Description

These extend the testthat::expect_is to have finer grain tests.

Usage

1
2
3
4
5
expect_is_not(object, class, info = NULL, label = NULL)

expect_is_exactly(object, class, info = NULL, label = NULL)

expect_all_inherit(object, class, info = NULL, label = NULL)

Arguments

object

the object in question.

class

the expected class object is to be.

info

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

label

object label. When NULL, computed from deparsed object.

Functions

See Also

Other class: class-tests

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Test to make sure an object is not of a class.
## Not run: 
# will return an error.
expect_is_not(1L, "numeric")

## End(Not run)

# but this is fine.
expect_is_not('a', "numeric")

expect_is_exactly('a', "character")

testextra documentation built on Dec. 18, 2019, 9:38 a.m.