Examples for 'testthat::expect_vector'


Does code return a vector with the expected size and/or prototype?

Aliases: expect_vector

Keywords:

### ** Examples

if (requireNamespace("vctrs") && packageVersion("vctrs") > "0.1.0.9002") {
expect_vector(1:10, ptype = integer(), size = 10)
show_failure(expect_vector(1:10, ptype = integer(), size = 5))
show_failure(expect_vector(1:10, ptype = character(), size = 5))
}
Loading required namespace: vctrs
Failed expectation:
`1:10` must have size 5, not size 10.
Failed expectation:
`1:10` must be a vector with type <character>.
Instead, it has type <integer>.

[Package testthat version 3.1.4 Index]