Results in TRUE only when all elements of current match the regular
expression in pattern. Matching is done by grepl.
Arguments
- current
[character]String(s) to check forpattern.- pattern
[character]A regular expression.- info
[character]scalar. Optional user-defined message. Must be a single character string. Multiline comments may be separated by"\n".- ...
passed to
grepl
See also
Other test-functions:
expect_equal(),
expect_equal_to_reference(),
expect_length(),
ignore()
Examples
expect_match("hello world", "world") # TRUE
#> ----- PASSED : <-->
#> call| eval(expr, envir)
expect_match("hello world", "^world$") # FALSE
#> ----- FAILED[data]: <-->
#> call| eval(expr, envir)
#> diff| Expected string that matches '^world$', got 'hello world'.
expect_match("HelLO woRlD", "world", ignore.case=TRUE) # TRUE
#> ----- PASSED : <-->
#> call| eval(expr, envir)
expect_match(c("apple","banana"), "a") # TRUE
#> ----- PASSED : <-->
#> call| eval(expr, envir)
expect_match(c("apple","banana"), "b") # FALSE
#> ----- FAILED[data]: <-->
#> call| eval(expr, envir)
#> diff| Not all strings match pattern 'b', for example element [1]: 'apple'