ok_group("Test addition", {
ok(1 + 1 == 2, "Can add 1")
ok(1 + 3 == 4, "Can add 3")
})
ok_group("Test subtraction", {
ok(1 - 1 == 0, "Can subtract 1")
ok(1 - 3 == -2, "Can subtract 3")
})
# Multiline group message
ok_group(c("Test multiplication", "but not division"),{
ok(1 * 1 == 1, "Can multiply by 1")
ok(2 * 3 == 6, "Can multiply by 3")
})
# Keep what happens in a group local
ok_group("Test addition of integers", local({
x <- 1L; y <- 2L
ok(x + y == 3L, "Can add integer variables")
}))
# \dontshow{
# Clear unittest result log, so our unittest failues don't fail example-building
unittest:::clear_outcomes()
# }
Run the code above in your browser using DataLab