packrat/lib/x86_64-w64-mingw32/3.4.3/stringr/tests/testthat/test-extract.r

context("Extract patterns")

test_that("single pattern extracted correctly", {
  test <- c("one two three", "a b c")

  expect_equal(
    str_extract_all(test, "[a-z]+"),
    list(c("one", "two", "three"), c("a", "b", "c"))
  )

  expect_equal(
    str_extract_all(test, "[a-z]{3,}"),
    list(c("one", "two", "three"), character())
  )

})

test_that("no match yields empty vector", {
  expect_equal(str_extract_all("a", "b")[[1]], character())
})
UBC-MDS/Karl documentation built on May 22, 2019, 1:53 p.m.