ut_cmp_error {unittest} | R Documentation |
Test for and compare errors generated by code
Description
A helper to catch expected errors and ensure they match what is expected
Usage
ut_cmp_error(code, expected_regexp, ignore.case = FALSE, perl = FALSE, fixed = FALSE)
Arguments
code |
Code expression to test, should generate an error |
expected_regexp |
Regular expression the error should match |
ignore.case |
Passed to |
perl |
Passed to |
fixed |
Passed to |
Value
Returns TRUE
if exp
generates an error and matches expected_regexp
.
Returns a string with expected and actual error if exp
generates an error but does not match.
Returns "No error returned"
if exp
does not generate an error.
Examples
ok(ut_cmp_error({
stop("Hammer time")
}, "hammer", ignore.case = TRUE), "Returned a hammer-based error")
[Package unittest version 1.6-1 Index]