tests/testthat/test_misc.R

context("Miscellaneous tests")

test_that("ggsave should save a *.tex file when used with 'device=tikzDevice::tikz", {
  ggsave_path = paste0(test_output_dir, "/ggsave.tex")
  if(file.exists(ggsave_path)) {
    file.remove(ggsave_path)
  }
  g = ggplot2::ggplot(data.frame())
  expect_error(ggplot2::ggsave(ggsave_path, g, device=tikzDevice::tikz), NA)
  expect_true(file.exists(ggsave_path))
})

test_that("closing tikz device with no error", {
  tikzDevice::tikz(onefile = FALSE)
  expect_error(dev.off(), NA)
})
yihui/tikzDevice documentation built on Dec. 5, 2023, 2:08 a.m.