tests/testthat/test_read_gate_data.R

library(batman)

context("Reading the file")


test_that("file is read properly", {

  normal_file <- "testdata/S06/s160518a.txt"
  empty_file <- "testdata/S01/a160624a.txt"

  expect_is(read_gate_data(normal_file),"data.frame")
  expect_error(read_gate_data(empty_file), "no data")
  expect_length(names(read_gate_data(normal_file)), 4)

})


context("Extracting year from file name")

test_that("year of a creation year is extracted", {
  expect_equal(.extract_year("a160428a.txt", "20"), "2016")
  expect_equal(.extract_year("S6/a160428a.txt", "20"), "2016")
})
zielinskipp/batman documentation built on May 12, 2019, 9:40 a.m.