From e8cebf716a5eb797d318e9c247613a54dcd522f2 Mon Sep 17 00:00:00 2001 From: "Trevor L. Davis" Date: Thu, 25 Apr 2024 10:22:30 -0700 Subject: [PATCH] tests: Add "area" and "histogram" geom tests --- tests/testthat/_snaps/geom/area.svg | 84 ++++++++++ tests/testthat/_snaps/geom/histogram.svg | 185 +++++++++++++++++++++++ tests/testthat/test-geom.R | 11 ++ 3 files changed, 280 insertions(+) create mode 100644 tests/testthat/_snaps/geom/area.svg create mode 100644 tests/testthat/_snaps/geom/histogram.svg diff --git a/tests/testthat/_snaps/geom/area.svg b/tests/testthat/_snaps/geom/area.svg new file mode 100644 index 0000000..8423c45 --- /dev/null +++ b/tests/testthat/_snaps/geom/area.svg @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +200 +400 +600 + + + + + + + + + +1875 +1900 +1925 +1950 +1975 +year +level +area + + diff --git a/tests/testthat/_snaps/geom/histogram.svg b/tests/testthat/_snaps/geom/histogram.svg new file mode 100644 index 0000000..c096a8f --- /dev/null +++ b/tests/testthat/_snaps/geom/histogram.svg @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +5000 +10000 +15000 + + + + + + + + + + +0 +1 +2 +3 +4 +5 +carat +count +histogram + + diff --git a/tests/testthat/test-geom.R b/tests/testthat/test-geom.R index 424d9a3..052f5f5 100644 --- a/tests/testthat/test-geom.R +++ b/tests/testthat/test-geom.R @@ -4,6 +4,12 @@ test_that("geometry patterns work as expected", { skip_if_not_installed("vdiffr") library("vdiffr") + expect_doppelganger("area", { + huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) + ggplot(huron, aes(year)) + + geom_area_pattern(aes(y = level)) + }) + expect_doppelganger("bar", { ggplot(ggplot2::mpg, aes(class)) + geom_bar_pattern( @@ -109,6 +115,11 @@ test_that("geometry patterns work as expected", { coord_fixed(ratio = 100) }) + expect_doppelganger("histogram", { + ggplot(diamonds, aes(carat)) + + geom_histogram_pattern(pattern = "stripe", bins = 30) + }) + expect_doppelganger("polygon", { angle <- seq(0, 2*pi, length.out = 7) + pi/6 polygon_df <- data.frame(