ut_cmp_error | R Documentation |
A helper to catch expected errors and ensure they match what is expected
ut_cmp_error(code, expected_regexp = NULL, expected_class = NULL,
ignore.case = FALSE, perl = FALSE, fixed = FALSE)
code |
Code expression to test, should generate an error |
expected_regexp |
Regular expression the error should match.
If |
expected_class |
Error class(es) that the error should match.
If |
ignore.case |
Passed to |
perl |
Passed to |
fixed |
Passed to |
Returns TRUE
if code
generates an error and, if they are specified (not NULL
),
the error matches expected_regexp
and/or expected_class
.
If an error is thrown by code
and expected_regexp
and/or expected_class
are given but do not match the error, returns a string with the expected and actual error message,
and the expected and actual error class generated.
Returns "No error returned"
if code
does not generate an error.
ok(ut_cmp_error({
stop("Hammer time")
}, "hammer", ignore.case = TRUE), "Returned a hammer-based error")
ok(ut_cmp_error({
stop(errorCondition("Hammer time", class = "MC"))
}, expected_mesage = "Hammer", expected_class = "MC"), "Returned a MC Hammer based error")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.