check/rimgtool.Rcheck/tests/testthat/test-compress.R

img <- array(1:24, dim = c(4, 4, 3))
img_wrong <- array(1:24, dim = c(4, 4))

test_that("test the output image of the compress function", {
  expect_equal(dim(compress(img, 2L))[1], dim(img)[1])
  expect_equal(length(dim(compress(img, 2L))), 3)
  expect_equal(dim(compress(img, 2L))[2], dim(img)[2])
})

test_that("test the error handling when invalid inputs are entered", {
  expect_error(compress(img, 5.1))
  expect_error(compress(img_wrong, 2))
  expect_error(compress(img, -3L))
})
UBC-MDS/rimgtool documentation built on March 29, 2020, 6:48 p.m.