| expect_match | R Documentation |
Do you expect a string to match this pattern?
expect_match(
object,
regexp,
perl = FALSE,
fixed = FALSE,
...,
all = TRUE,
info = NULL,
label = NULL
)
expect_no_match(
object,
regexp,
perl = FALSE,
fixed = FALSE,
...,
all = TRUE,
info = NULL,
label = NULL
)
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. |
regexp |
Regular expression to test against. |
perl |
logical. Should Perl-compatible regexps be used? |
fixed |
If |
... |
Arguments passed on to
|
all |
Should all elements of actual value match |
info |
Extra information to be included in the message. This argument is soft-deprecated and should not be used in new code. Instead see alternatives in quasi_label. |
label |
Used to customise failure messages. For expert use only. |
expect_match() checks if a character vector matches a regular expression,
powered by grepl().
expect_no_match() provides the complementary case, checking that a
character vector does not match a regular expression.
expect_no_match(): Check that a string doesn't match a regular
expression.
Other expectations:
comparison-expectations,
equality-expectations,
expect_error(),
expect_length(),
expect_named(),
expect_null(),
expect_output(),
expect_reference(),
expect_silent(),
inheritance-expectations,
logical-expectations
expect_match("Testing is fun", "fun")
expect_match("Testing is fun", "f.n")
expect_no_match("Testing is fun", "horrible")
show_failure(expect_match("Testing is fun", "horrible"))
show_failure(expect_match("Testing is fun", "horrible", fixed = TRUE))
# Zero-length inputs always fail
show_failure(expect_match(character(), "."))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.