tests/testthat/test-read.R

library(ggplot2)
library(readr)

tmp_csv <- tempfile(fileext = ".csv")
tmp_tsv <- tempfile(fileext = ".tsv")

write_csv(diamonds, tmp_csv)
write_tsv(diamonds, tmp_tsv)

test_that("read csv file with explit delim", {
  x <- read_delim_dumb(tmp_csv, delim = ",")
  expect_type(x$cut, "character")
  expect_type(x$x, "character")
})

test_that("read csv file with implicit comma", {
  x <- read_csv_dumb(tmp_csv)
  expect_type(x$cut, "character")
  expect_type(x$x, "character")
})

test_that("read csv file with implicit tab", {
  x <- read_tsv_dumb(tmp_tsv)
  expect_type(x$cut, "character")
  expect_type(x$x, "character")
})

Try the k5 package in your browser

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

k5 documentation built on May 29, 2024, 7:48 a.m.