tests/testthat/test-integer-arrays.R

test_that("integer arrays work", {

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # 8 bit
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  for (im in test_image$array_int) {
    expect_identical(
      write_png(im) |> read_png(type = 'array', array_type = 'int'),
      im
    )
  }
  
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # 16 bit
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  for (im in test_image$array_int_16bit) {
    expect_identical(
      write_png(im, bits = 16) |> read_png(type = 'array', array_type = 'int'),
      im
    )
  }
  
  
})

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.