tests/testthat/test-writeijroi.R

path <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi")

context("Writing an ROI to file")

testthat::test_that("write.ijroi() produces files that are consistent with the structure written", {

  name_roi <- dir(path, pattern = "*.roi")

  tmpDir <- tempdir()
  for (i in 1:length(name_roi)) {

    r <- RImageJROI::read.ijroi(file.path(path, name_roi[i]))
    RImageJROI::write.ijroi(file = file.path(tmpDir, name_roi[i]), roi = r, verbose = FALSE)

    r_2 <- RImageJROI::read.ijroi(file = file.path(tmpDir, name_roi[i]), verbose = FALSE)

    tryCatch(
      expr = {
        testthat::expect_identical(r, r_2)
      },
      error = function(e){
        print(name_roi[i])
        print(e)
      }
    )
  }
})

Try the RImageJROI package in your browser

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

RImageJROI documentation built on Sept. 11, 2024, 8:09 p.m.