tests/testthat/helper-capture_output.R

if (utils::packageVersion("testthat") <= "1.0.2") {
  capture_output <- function(code, print = FALSE, width = 80) {
    oldwidth <- getOption("width")
    if (width != oldwidth) {
      skip_if_not(
        with(R.Version(), paste(major, minor, sep = ".")) >= "3.4.0",
        "Setting width fails on R < 3.4.0"
      )

      options(width = width)
      on.exit(options(width = oldwidth), add = TRUE)
    }
    testthat::capture_output(code, print)
  }
}

Try the utf8 package in your browser

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

utf8 documentation built on June 8, 2025, 9:31 p.m.