tests/testthat/test-any_of.R

context("test-rx_any_of")

test_that("any_of rule works", {
  # expect bare output
  expect_equal(rx() %>% rx_any_of(value = "") %>% as.character(), "[]")

  # expect match
  expect_true(grepl(rx() %>% rx_any_of(value = "abc"), "b"))

  # expect no match
  expect_false(grepl(rx() %>% rx_any_of(value = "abc"), "d"))

  # expect pipe functionality
  expect_equal(rx_any_of(.data = "^", value = "abc") %>% as.character(), "^[abc]")

  # expect correct number of matches
  expect_true(length(unlist(regmatches("abba", gregexpr(rx() %>% rx_any_of(value = "a"), "abba")))) == 2)

})

Try the RVerbalExpressions package in your browser

Any scripts or data that you put into this service are public.

RVerbalExpressions documentation built on Nov. 6, 2019, 5:08 p.m.