is_a {testthat} | R Documentation |
Tests whether or not an object inherits from any of a list of classes.
is_a(class) expect_is(object, class, info = NULL, label = NULL)
class |
character vector of class names |
object |
object to test |
info |
extra information to be included in the message (useful when writing tests in loops). |
label |
object label. When |
Other expectations: equals
,
expect_equal
,
expect_equivalent
,
expect_error
, expect_false
,
expect_identical
,
expect_match
, expect_message
,
expect_output
, expect_true
,
expect_warning
,
gives_warning
,
is_equivalent_to
, is_false
,
is_identical_to
, is_true
,
matches
, prints_text
,
shows_message
,
takes_less_than
, throws_error
expect_that(1, is_a("numeric")) a <- matrix(1:10, nrow = 5) expect_that(a, is_a("matrix")) expect_that(mtcars, is_a("data.frame")) expect_is(mtcars, "data.frame") # alternatively for classes that have an is method expect_that(is.data.frame(mtcars), is_true()) # doesn't read quite as nicely