Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

expect_length

Does code return a vector with the specified length?


Description

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.

See Also

expect_vector() to make assertions about the "size" of a vector

Examples

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

## Not run: 
expect_length(1:10, 1)

## End(Not run)

testthat

Unit Testing for R

v3.0.2
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], RStudio [cph, fnd], R Core team [ctb] (Implementation of utils::recover())
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.