File: test-check.r

package info (click to toggle)
r-cran-stringr 0.6.2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 308 kB
  • sloc: makefile: 3
file content (22 lines) | stat: -rw-r--r-- 647 bytes parent folder | download
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"))
})