matches {testthat}R Documentation

Expectation: does string match regular expression?

Description

If the object to be tested has length greater than one, all elements of the vector must match the pattern in order to pass.

Usage

matches(regexp, all = TRUE, ...)

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

Arguments

regexp

regular expression to test against

all

should all elements of actual value match regexp (TRUE), or does only one need to match (FALSE)

...

For matches: other arguments passed on to grepl. For expect_match: other arguments passed on to matches.

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_reference, expect_equal_to_reference; equals, expect_equal; expect-compare, expect_less_than, expect_more_than, is_less_than, is_more_than; expect_equivalent, is_equivalent_to; expect_error, throws_error; expect_false, expect_true, is_false, is_true; expect_identical, is_identical_to; expect_is, is_a; expect_message, shows_message; expect_named, has_names; expect_null, is_null; expect_output, prints_text; expect_warning, gives_warning; takes_less_than

Examples

expect_match("Testing is fun", "fun")
expect_match("Testing is fun", "f.n")

[Package testthat version 0.9.1 Index]