tests/testthat/test_detect_delim.R

context("detect_delim")

test_that("detects lf delimiters correctly", {
  path <- tempfile()
  writeChar("asdf\rasdf\rasdf\r", path)
  on.exit({
    unlink(path)
  })

  expect_equal(detect_delim(path), "\r")
})

test_that("detects crlf delimiters correctly", {
  path <- tempfile()
  writeChar("asdf\r\nasdf\r\nasdf\r\n", path)
  on.exit({
    unlink(path)
  })

  expect_equal(detect_delim(path), "\r\n")
})

test_that("falls back to crlf when it find sno delimiters", {
  path <- tempfile()
  writeChar("asdf", path)
  on.exit({
    unlink(path)
  })

  expect_equal(detect_delim(path), "\r\n")
})

test_that("warns and falls back on file not found", {
  expect_equal(suppressWarnings(detect_delim("idontexist")), "\r\n")
})

Try the EML package in your browser

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

EML documentation built on April 29, 2022, 1:06 a.m.