Check that current is an S4 object that is of class class

expect_s4_class(current, class, ..., info = NA_character_)

Arguments

current

[R object or expression] Object or expression to be tested

class

[character] Expected class of current; may optionally pass NA to assert that current is not an object

...

Ignored

info

[character(1L)] Optional user-defined message; must be a single string value

Value

A tinytest object. A tinytest object is a logical with attributes holding information about the test that was run

See also

testthat equivalent: testthat::expect_s4_class()

Other typing expectation predicates: expect_s3_class(), expect_type()

Examples

expect_s4_class(Matrix::Matrix(), "Matrix") # Pass
#> ----- PASSED      : <-->
#>  call| expect_s4_class(Matrix::Matrix(), "Matrix") 
expect_s4_class(data.frame(), "data.frame") # Fail
#> ----- FAILED[attr]: <-->
#>  call| expect_s4_class(data.frame(), "data.frame")
#>  diff| Expected an S4 object, got a non-S4 object 
expect_s4_class(data.frame(), NA) # Pass
#> ----- PASSED      : <-->
#>  call| expect_s4_class(data.frame(), NA)