Tests whether or not an object inherits from any of a list of classes, or
is an instance of a base type.
expect_null() is a special case designed
expect_null(object, info = NULL, label = NULL) expect_type(object, type) expect_is(object, class, info = NULL, label = NULL) expect_s3_class(object, class) expect_s4_class(object, class)
object to test
extra information to be included in the message (useful when writing tests in loops).
object label. When
String giving base type (as returned by
character vector of class names
expect_is() is an older form. I'd recommend using
expect_s4_class() in order to more clearly convey intent.
expect_is(1, "numeric") a <- matrix(1:10, nrow = 5) expect_is(a, "matrix") expect_is(mtcars, "data.frame") # alternatively for classes that have an is method expect_true(is.data.frame(mtcars)) f <- factor("a") expect_is(f, "factor") expect_s3_class(f, "factor") expect_type(f, "integer") expect_null(NULL)