Check the class membership of an argument
checkMultiClass(x, classes, null.ok = FALSE)check_multi_class(x, classes, null.ok = FALSE)
assertMultiClass(x, classes, null.ok = FALSE, .var.name = vname(x), add = NULL)
assert_multi_class(
x,
classes,
null.ok = FALSE,
.var.name = vname(x),
add = NULL
)
testMultiClass(x, classes, null.ok = FALSE)
test_multi_class(x, classes, null.ok = FALSE)
expect_multi_class(x, classes, null.ok = FALSE, info = NULL, label = vname(x))
[any] Object to check.
[character]
Class names to check for inheritance with inherits.
x must inherit from any of the specified classes.
[logical(1)]
If set to TRUE, x may also be NULL.
In this case only a type check of x is performed, all additional checks are disabled.
[character(1)]
Name of the checked object to print in assertions. Defaults to
the heuristic implemented in vname.
[AssertCollection]
Collection to store assertion messages. See AssertCollection.
[character(1)]
Extra information to be included in the message for the testthat reporter.
See expect_that.
[character(1)]
Name of the checked object to print in messages. Defaults to
the heuristic implemented in vname.
Depending on the function prefix:
If the check is successful, the functions
assertMultiClass/assert_multi_class return
x invisibly, whereas
checkMultiClass/check_multi_class and
testMultiClass/test_multi_class return
TRUE.
If the check is not successful,
assertMultiClass/assert_multi_class
throws an error message,
testMultiClass/test_multi_class
returns FALSE,
and checkMultiClass returns a string with the error message.
The function expect_multi_class always returns an
expectation.
Other attributes:
checkClass(),
checkNamed(),
checkNames()
Other classes:
checkClass(),
checkR6()
# NOT RUN {
x = 1
class(x) = "bar"
checkMultiClass(x, c("foo", "bar"))
checkMultiClass(x, c("foo", "foobar"))
# }
Run the code above in your browser using DataLab