tests/testthat/test-read_file.R

test_that("read_file reads empty files", {
  tmp <- tempfile()
  on.exit(unlink(tmp))

  writeBin(charToRaw(""), tmp)

  expect_equal(read_file(tmp), character())
})

works_with <- function(contents) {
  tmp <- tempfile()
  on.exit(unlink(tmp))

  writeBin(charToRaw(contents), tmp)

  expect_equal(read_file(tmp), contents)
}

test_that("read_file reads the entire file", {
  works_with("foo")
  works_with("foo\nbar")
  works_with("foo\nbar\n")
  works_with("foo\r\nbar\r\n")
})

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.