tests/testthat/test_getfolderstructure.R

library(GGIR)
context("getfolderstructure")
test_that("getfolderstructure", {
  dn = "A" # name of the datadir folder
  if (file.exists(dn)) unlink(dn, recursive = TRUE)
  dummyfolderA = "A"
  dummyfolderB = "B"
  dummyfolderC = "C"
  dir.create(file.path("A"))
  dir.create(file.path("A/B"))
  dir.create(file.path("A/C"))
  
  write.csv(matrix(0, 4, 4), file = "A/B/testB.csv")
  write.csv(matrix(0, 4, 4), file = "A/C/testC.csv")
  
  folderstructure = getfolderstructure(datadir = dn,
                                       referencefnames = c("testB.csv", "testC.csv"))
  expect_that(  folderstructure$foldername[1],equals("B"))
  expect_that(  folderstructure$foldername[2],equals("C"))
  if (file.exists(dn))
    unlink(dn, recursive = TRUE
    )
})

Try the GGIR package in your browser

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

GGIR documentation built on Oct. 17, 2023, 1:12 a.m.