Learn R Programming

testextra (version 0.1.0.1)

class-expectations: Class Expectations

Description

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

Usage

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

  • expect_is_not: test that an object does not inherit from a class.

  • expect_is_exactly: test that an object is exactly a specific class and not a child class.

  • expect_all_inherit: test that all elements of a list inherit a given class.

See Also

Other class: class-tests

Examples

Run this code
# NOT RUN {
# Test to make sure an object is not of a class.
# }
# NOT RUN {
# will return an error.
expect_is_not(1L, "numeric")
# }
# NOT RUN {
# but this is fine.
expect_is_not('a', "numeric")

expect_is_exactly('a', "character")
# }

Run the code above in your browser using DataLab