File: test-detect.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 (23 lines) | stat: -rw-r--r-- 774 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
23
context("Detecting patterns")

test_that("special cases are correct", {
  expect_that(str_detect(NA, ""), equals(NA))
  expect_that(str_detect(character(), ""), equals(logical()))
})

test_that("vectorised patterns work", {
  expect_that(str_detect("ab", c("a", "b", "c")), equals(c(T, T, F)))
  expect_that(str_detect(c("ca", "ab"), c("a", "c")), equals(c(T, F)))
})

test_that("modifiers work", {
  expect_that(str_detect("ab", "AB"), equals(FALSE))
  expect_that(str_detect("ab", ignore.case("AB")), equals(TRUE))

  expect_that(str_detect("abc", "ab[c]"), equals(TRUE))
  expect_that(str_detect("abc", fixed("ab[c]")), equals(FALSE))
  expect_that(str_detect("ab[c]", fixed("ab[c]")), equals(TRUE))

  expect_that(str_detect("abc", perl("(?x)a b c")), equals(TRUE))

})