tests/tinytest/test-utils.R

source("helpers.R")

exit_if_not(requireNamespace("stringi", quietly = TRUE))

x <- "hi there ; this is a string"

expect_equal(
  {
    y <- x
    astgrepr:::my_stri_sub(y, 1, 1) <- "AAAA"
    y
  },
  {
    y <- x
    stringi::stri_sub(y, 1, 1) <- "AAAA"
    y
  }
)

expect_equal(
  {
    y <- x
    astgrepr:::my_stri_sub(y, 1, 3) <- "AAAA"
    y
  },
  {
    y <- x
    stringi::stri_sub(y, 1, 3) <- "AAAA"
    y
  }
)

expect_equal(
  {
    y <- x
    astgrepr:::my_stri_sub(y, 5, 10) <- "AAAA"
    y
  },
  {
    y <- x
    stringi::stri_sub(y, 5, 10) <- "AAAA"
    y
  }
)

Try the astgrepr package in your browser

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

astgrepr documentation built on June 8, 2025, 11:05 a.m.