R: Expectation: does string/output/message/warning/error match a...

expect_match {testthat} | R Documentation

## Expectation: does string/output/message/warning/error match a regular expression?

### Description

Expectation: does string/output/message/warning/error match a regular expression?

### Usage

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

### Arguments

`object` | object to test
`regexp` | Regular expression to test against.
`...` | Additional arguments passed on to `grepl`, e.g. `ignore.case` or `fixed`.
`all` | Should all elements of actual value match `regexp` (TRUE), or does only one need to match (FALSE)
`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: `comparison-expectations`, `equality-expectations`, `expect_equal_to_reference`, `expect_length`, `expect_named`, `inheritance-expectations`, `logical-expectations`, `output-expectations`

### Examples

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

    ## Not run:
    expect_match("Testing is fun", "horrible")

    # Zero-length inputs always fail
    expect_match(character(), ".")

    ## End(Not run)

[Package testthat version 1.0.2 Index]