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 Dec. 11, 2021, 10:09 a.m.