tests/testthat/test-tiff.R

test_that("TIFF file signature", {
  skip_if_not("tiff" %in% ugd_renderers()$id, "TIFF renderer not installed")

  # TIFF has a different signature depending on endianness
  file_magic_le <- as.raw(c(0x49, 0x49, 0x2A, 0x00))
  file_magic_be <- as.raw(c(0x4D, 0x4D, 0x00, 0x2A))

  ugd_magic <- ugd_render_inline({
        plot(1)
    }, as = "tiff")[seq_along(file_magic_le)]

  expect_true(
    all.equal(file_magic_le, ugd_magic) ||
    all.equal(file_magic_be, ugd_magic)
  )
})

Try the unigd package in your browser

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

unigd documentation built on April 3, 2025, 6:11 p.m.