Skip to content

Commit 465a9ff

Browse files
committed
add test
1 parent 30cb270 commit 465a9ff

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/testthat/test-data_summary.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,25 @@ test_that("data_summary, print", {
139139
out <- data_summary(mtcars, MW = mean(mpg), SD = sd(mpg), by = c("am", "gear"))
140140
expect_snapshot(print(out))
141141
})
142+
143+
144+
test_that("data_summary, inside functions", {
145+
foo1 <- function(x, ...) {
146+
datawizard::data_summary(x, ..., by = "Species")
147+
}
148+
149+
foo2 <- function(x, by, ...) {
150+
datawizard::data_summary(x, ..., by = by)
151+
}
152+
153+
foo3 <- function(x, by) {
154+
datawizard::data_summary(x, MW = mean(Sepal.Width), by = by)
155+
}
156+
157+
data(iris)
158+
out1 <- foo1(iris, MW = mean(Sepal.Width))
159+
out2 <- foo2(iris, by = "Species", MW = mean(Sepal.Width))
160+
out3 <- foo3(iris, "Species")
161+
expect_equal(out1$MW, out2$MW, tolerance = 1e-4)
162+
expect_equal(out1$MW, out3$MW, tolerance = 1e-4)
163+
})

0 commit comments

Comments
 (0)