Skip to content

Commit

Permalink
fixed system dependency in test
Browse files Browse the repository at this point in the history
  • Loading branch information
pepijn-devries committed Jul 28, 2024
1 parent 08a4f71 commit 77d8c58
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions tests/testthat/test_plots.r
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,29 @@ test_that(
"Negative radii throws error in continuous scales", {
expect_error({
on.exit({grDevices::dev.off(); closeAllConnections()})
dat <- raw()
con <- rawConnection(dat, "w")
f <- tempfile(fileext = ".pdf")
p <- ggplot() +
geom_stars(data = sw_sub) +
geom_fields(data = sw_sub,
aes(angle = as.numeric(atan2(vo, uo)),
radius = -as.numeric(pythagoras(uo, vo))))
grDevices::png(con)
grDevices::pdf(f)
print(p) |> suppressMessages()
close(con)
})
})

test_that(
"Binned scales work without error", {
expect_no_error({
on.exit({grDevices::dev.off(); closeAllConnections()})
dat <- raw()
con <- rawConnection(dat, "w")
f <- tempfile(fileext = ".pdf")
p <- ggplot() +
geom_stars(data = sw_sub) +
geom_fields(data = sw_sub,
aes(angle = as.numeric(atan2(vo, uo)),
radius = as.numeric(pythagoras(uo, vo)))) +
scale_radius_binned()
grDevices::png(con)
grDevices::pdf(f)
print(p) |> suppressMessages()
})
})
Expand All @@ -99,15 +96,14 @@ test_that(
"Discrete scales work without error", {
expect_no_error({
on.exit({grDevices::dev.off(); closeAllConnections()})
dat <- raw()
con <- rawConnection(dat, "w")
f <- tempfile(fileext = ".pdf")
p <- ggplot() +
geom_stars(data = sw_sub) +
annotation_fields(data = sw_sub,
aes(angle = as.numeric(atan2(vo, uo)),
radius = cut(as.numeric(pythagoras(uo, vo)), 3))) +
scale_radius_discrete()
grDevices::png(con)
grDevices::pdf(f)
print(p) |> suppressMessages()
})
})

0 comments on commit 77d8c58

Please sign in to comment.