tests/testthat/test-raw-spec.R

test_that("raw_spec detects missing specs", {
  
  im <- as.raw(1:10)
  write_png(im, raw_spec = list(bits = 8, height = 2, width = 5, depth = 1))
  
  expect_error(
    write_png(im, raw_spec = list(bits = 8, height = 2, width = 5, greg = 1)),
    "depth"
  )
  
  
  expect_error(
    write_png(im, raw_spec = list(greg = 8, height = 2, width = 5, depth = 1)),
    "bits"
  )
  
})

Try the fastpng package in your browser

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

fastpng documentation built on April 3, 2025, 10:01 p.m.