1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
context("String and pattern checks")
test_that("string is atomic", {
expect_that(check_string(list()),
throws_error("must be an atomic"))
})
test_that("pattern is a string", {
expect_that(check_pattern(1),
throws_error("must be a character vector"))
})
test_that("error when string and pattern lengths incompatible", {
expect_that(check_pattern(letters, "a"), equals(letters))
expect_that(check_pattern("a", letters), equals("a"))
expect_that(check_pattern(c("a", "b", "c"), c("a", "b")),
throws_error("not compatible"))
expect_that(check_pattern(c("a", "b"), c("a", "b", "c")),
throws_error("not compatible"))
})
|