🔍 An RStudio addin slash regex utility belt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
564B

  1. context("test-wrap_regex.R")
  2. test_that("wrap_regex generally works", {
  3. expect_equal(wrap_regex("(a)(b)"),
  4. "<span class=\"g01\">(a)</span><span class=\"g02\">(b)</span>")
  5. })
  6. test_that("wrap_regex doesn't add parens", {
  7. expect_equal(wrap_regex("\\ba", exact = FALSE), "\\ba")
  8. })
  9. test_that("wrap_regex doesn't wrap non-capture groups", {
  10. expect_equal(wrap_regex("(?:a)(b)"), "(?:a)<span class=\"g01\">(b)</span>")
  11. expect_equal(wrap_regex("((?:a(b))c)"),
  12. "<span class=\"g01\">((?:a<span class=\"g02\">(b)</span>)c)</span>")
  13. })