Extra Check Functions for RUnit

Usage

checkWarning(expr, expected = NULL, msg = NULL)

Arguments

expr
an R expression
expected
expected value or regular expression pattern
msg
informative message to add to the error in case of failure

Description

checkWarning checks if a warning is generated by an expression, and optionally follows an expected regular expression pattern.

Examples

# check warnings
checkWarning({ warning('ah ah'); 3})
Using RUnit framework provider: RUnit Warning message: ah ah
[1] TRUE
checkWarning({ warning('ah oh ah'); 3}, 'oh')
Warning message: ah oh ah
[1] TRUE
try( checkWarning(3) )
try( checkWarning({ warning('ah ah'); 3}, 'warn you') )
Warning message: ah ah