Skip to content

Commit

Permalink
Add vdiffr test
Browse files Browse the repository at this point in the history
  • Loading branch information
yutannihilation committed Sep 28, 2024
1 parent 18bbb96 commit 413d56e
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Imports:
tibble,
cli
Suggests:
testthat (>= 3.0.0)
testthat (>= 3.0.0),
vdiffr
URL: https://yutannihilation.github.io/string2path/, https://github.com/yutannihilation/string2path
BugReports: https://github.com/yutannihilation/string2path/issues
Encoding: UTF-8
Expand Down
110 changes: 110 additions & 0 deletions tests/testthat/_snaps/snapshot/path-and-fill-match.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions tests/testthat/test-snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@ test_that("the data extracted from installed font are as expected", {
expect_snapshot(string2stroke("A", "Arial"))
expect_snapshot(string2fill("A", "Arial"))
})

test_that("path and fill match", {
skip_if_not(isTRUE("Arial" %in% dump_fontdb()$family))
skip_if_not_installed("vdiffr")

do_plot_s <- function() {
p <- string2path("s", "Arial", tolerance = 3e-3)
f <- string2fill("s", "Arial", tolerance = 3e-3)

plot(NULL, xlim = c(0, 0.45), ylim = c(0, 0.45))
for (tri in split(f, f$triangle_id)) {
polygon(tri$x, tri$y, col = "#ff3344", border = "transparent")
}
lines(p$x, p$y, lwd = 10)
}
vdiffr::expect_doppelganger("path and fill match", do_plot_s())
})

0 comments on commit 413d56e

Please sign in to comment.