Learn R Programming

testthat (version 0.6)

prints_text: Expectation: does printed output match a regular expression?

Description

Expectation: does printed output match a regular expression?

Usage

prints_text(regexp, ...)

expect_output(object, regexp, ..., info = NULL, label = NULL)

Arguments

regexp
regular expression to test against
...
other arguments passed to grepl
object
object to test
info
extra information to be included in the message (useful when writing tests in loops).
label
object label. When NULL, computed from deparsed object.

See Also

Other expectations: equals, expect_equal, expect_equivalent, expect_error, expect_false, expect_identical, expect_is, expect_match, expect_message, expect_true, expect_warning, gives_warning, is_a, is_equivalent_to, is_false, is_identical_to, is_true, matches, shows_message, takes_less_than, throws_error

Examples

Run this code
str(mtcars)
expect_that(str(mtcars), prints_text("32 obs"))
expect_that(str(mtcars), prints_text("11 variables"))
expect_output(str(mtcars), "11 variables")

Run the code above in your browser using DataLab