ttm_expect_equal | R Documentation |
Test that multi: expect equal
ttm_expect_equal(
object,
expected,
...,
tolerance = if (testthat::edition_get() >= 3) testthat::testthat_tolerance(),
info = NULL,
label = NULL,
expected.label = NULL,
verbose = 0
)
object |
Object to check if equal to expected |
expected |
Expected value |
... |
Args passed to testthat::expect_equal() |
tolerance |
Passed to 'testthat::expect_true()'. |
info |
Passed to 'testthat::expect_true()'. |
label |
Passed to 'testthat::expect_true()'. |
expected.label |
Passed to 'testthat::expect_true()'. |
verbose |
Amount of info that should be printed. |
Test result
set.seed(0)
# 1 attempt, all pass
ttm(1, {
ttm_expect_equal(TRUE, TRUE)
ttm_expect_equal(1, 1)
ttm_expect_equal(1:5, 1:5)
})
# Fails first 6 times, then passes
ttm(100, {
x <- sample(1:6, 1)
print(x)
ttm_expect_equal(x, 3)
})
# Will always fail regardless of number of attempts
try({
ttm(3, {
ttm_expect_equal(1, 2)
})
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.