tests/testthat/test-readLines.R

test_that("readLines works", {
  tmp <- tempfile()
  on.exit(unlink(tmp))

  writeLines("foo\nbar\n", tmp)

  # Errors with connections
  con <- file(tmp)
  expect_error(readLines(con), "Only file paths are supported")
  close(con)

  # Warns if you use ok, warn, encoding or skipNul
  expect_warning(readLines(tmp, ok = TRUE), "is ignored")
  expect_warning(readLines(tmp, warn = TRUE), "is ignored")
  expect_warning(readLines(tmp, encoding = "Latin-1"), "is ignored")
  expect_warning(readLines(tmp, skipNul = TRUE), "is ignored")
})

Try the brio package in your browser

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

brio documentation built on May 29, 2024, 6:41 a.m.