Skip to content

Commit 053f2a5

Browse files
committed
add test
1 parent 4073bcb commit 053f2a5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/testthat/test-stat-bin.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ test_that("stat_bin() provides width (#3522)", {
118118
expect_equal(out$xmax - out$xmin, rep(binwidth, 10))
119119
})
120120

121+
test_that("stat_bin(keep.zeroes) options work as intended", {
122+
p <- ggplot(data.frame(x = c(1, 2, 2, 3, 5, 6, 6, 7)), aes(x)) +
123+
scale_x_continuous(limits = c(-1, 9))
124+
125+
ld <- layer_data(p + geom_histogram(binwidth = 1, keep.zeroes = "all"))
126+
expect_equal(ld$x, -1:9)
127+
128+
ld <- layer_data(p + geom_histogram(binwidth = 1, keep.zeroes = "inner"))
129+
expect_equal(ld$x, c(1:7))
130+
131+
ld <- layer_data(p + geom_histogram(binwidth = 1, keep.zeroes = "none"))
132+
expect_equal(ld$x, c(1:3, 5:7))
133+
})
134+
121135
# Underlying binning algorithm --------------------------------------------
122136

123137
test_that("bins() computes fuzz with non-finite breaks", {

0 commit comments

Comments
 (0)