ok | R Documentation |
Report the test of an expression in TAP format.
ok(test, description)
test |
Expression to be tested. Evaluating to |
description |
Character string describing the test. If a description is not given a character representation of the test expression will be used. |
See unittest
package documentation.
The unittest.output
option tells unittest where output should be sent.
This is most useful for vignettes, where sending output to
stderr
separates the unittest output from the vignette itself.
ok()
returns whatever was returned when test
is evaluated.
More importantly it has the side effect of printing the result of the
test in TAP
format.
ok(1==1, "1 equals 1")
ok(1==1)
ok(1==2, "1 equals 2")
ok(all.equal(c(1,2),c(1,2)), "compare vectors")
fn <- function () stop("oops")
ok(fn(), "something with a coding error")
ok(c("Some diagnostic", "messages"), "A failure with diagnostic messages")
## Send unittest output to stderr()
options(unittest.output = stderr())
ok(ut_cmp_equal(4, 5), "4 == 5? Probably not")
## Reset unittest output to default (stdout())
options(unittest.output = NULL)
ok(ut_cmp_equal(4, 5), "4 == 5? Probably not")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.