tests/testthat/test-reg_matches.R

test_that("`reg_matches()`: basic usage", {
  x <- c("sdtm.oak", "sdtm.cdisc", "adam")
  m <- gregexpr("sdtm", x, fixed = TRUE)

  # `regmatches()` returns `character(0)` for `"adam"`
  # But `reg_matches()` returns `NA` for `"adam"`
  expect_identical(reg_matches(x, m), list("sdtm", "sdtm", NA_character_))
})

Try the sdtm.oak package in your browser

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

sdtm.oak documentation built on April 3, 2025, 9:37 p.m.