From e51132fdb863fab88171190522b85f0c884ac236 Mon Sep 17 00:00:00 2001 From: Heike Hofmann Date: Mon, 29 Jan 2024 09:00:53 -0600 Subject: [PATCH] set larger tolerance --- tests/testthat/test-ggparallel.R | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-ggparallel.R b/tests/testthat/test-ggparallel.R index 43d3d1c..dc9e698 100644 --- a/tests/testthat/test-ggparallel.R +++ b/tests/testthat/test-ggparallel.R @@ -1,3 +1,12 @@ +save_png <- function(code, width = 400, height = 400) { + path <- tempfile(fileext = ".png") + png(path, width = width, height = height) + on.exit(dev.off()) + code + + path +} + test_that("ggparallel works", { load(system.file("mtcars.rda", package="ggparallel")) # loads object test_mtcars_plot built_saved <- ggplot2::ggplot_build(test_mtcars_plot) @@ -23,10 +32,11 @@ test_that("ggparallel hammocks work", { titanic <- as.data.frame(Titanic) titanic_plot <- ggparallel(names(titanic)[c(1,4,2,3)], titanic, weight=1, asp=0.5, - method="hammock", ratio=0.2, order=c(0,0)) + method="hammock", ratio=0.2, order=c(0,0)) build_now <- ggplot2::ggplot_build(titanic_plot) -# titanic_hammock <- build_now$data -# save(titanic_hammock, file="inst/titanic_hammock.rda") + # titanic_hammock <- build_now$data + # save(titanic_hammock, file="inst/titanic_hammock.rda") - expect_identical(titanic_hammock, build_now$data) + expect_equal(titanic_hammock, build_now$data, tolerance=1e-4) }) +