Skip to content

Does code return a vector with the specified length?

Usage

expect_length(object, n)

Arguments

object

Object to test.

Supports limited unquoting to make it easier to generate readable failures within a function or for loop. See quasi_label for more details.

n

Expected length.

Examples

expect_length(1, 1)
expect_length(1:10, 10)

if (FALSE) { # \dontrun{
expect_length(1:10, 1)
} # }