tests/testthat/test-file_line_endings.R

test_that("file_line_endings detects Unix line endings", {
  tmp <- tempfile()
  on.exit(unlink(tmp))

  writeBin(charToRaw("foo\n"), tmp)

  expect_equal(file_line_endings(tmp), "\n")

  writeBin(charToRaw(""), tmp)

  expect_identical(file_line_endings(tmp), NA_character_)
})

test_that("file_line_endings detects Windows line endings", {
  tmp <- tempfile()
  on.exit(unlink(tmp))

  writeBin(charToRaw("foo\r\n"), tmp)

  expect_equal(file_line_endings(tmp), "\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.