tests/testthat/test-1-2-0_any_grepl.R

context("any grepl")

test_that("any_grepl", {
  expect_true(any_grepl(c("A_D_E", "K0j"), "[a-z]"))
  expect_true(any_grepl(c("A_D_E", "K0j"), "[A-Z]"))
  expect_false(any_grepl(c("A_D_E", "K0j"), "[A-Z]{2}"))
  expect_false(any_grepl(c("A_D_E", "K0j"), "k.j"))
  expect_false(any_grepl(c("A_D_E", "K0j"), "k.j", fixed = TRUE))
  expect_true(any_grepl(c("A_D_E", "K0j"), "k.j", ignore.case = TRUE))
  expect_true(any_grepl(c("A_D_E", "K0j"), "k0j", ignore.case = TRUE, fixed = TRUE, quiet = TRUE))
  expect_message(any_grepl(c("A_D_E", "K0j"), "k0j", ignore.case = TRUE, fixed = TRUE), 
                 regexp = "so considering both upper and lowercase")
})

Try the hutils package in your browser

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

hutils documentation built on April 13, 2022, 5:23 p.m.