Skip to content

Commit 093c509

Browse files
committed
a few more tests for edge cases
1 parent df3cd8d commit 093c509

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

tests/testthat/test-convenience-functions.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ test_that("calc_v (internal function) works", {
3939
expect_identical(calc_v(a, median), 2.5)
4040
expect_equal(calc_v(c(a, NA), mean), NA_real_)
4141
expect_identical(calc_v(c(a, NA), min, list(na.rm = TRUE)), 1L)
42+
expect_error(calc_v(fun = "mean"), "'v' can't be missing")
4243
})
4344

4445
# lbub --------------------------------------------------------------------

tests/testthat/test-mcmc-combo.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ source(test_path("data-for-mcmc-tests.R"))
55

66
test_that("mcmc_combo returns a gtable object", {
77
expect_gtable(mcmc_combo(arr, regex_pars = "beta"))
8+
expect_gtable(mcmc_combo(arr, regex_pars = "beta",
9+
gg_theme = ggplot2::theme_dark()))
810
expect_gtable(mcmc_combo(mat, regex_pars = "beta",
911
binwidth = 1/20, combo = c("dens", "hist"),
1012
facet_args = list(nrow = 2)))

tests/testthat/test-ppc-errors.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ test_that("ppc_error_binned returns ggplot object", {
4646
expect_gg(ppc_error_binned(rep(y, 2), cbind(Ey, Ey)))
4747
})
4848

49+
test_that("bin_errors works for edge cases", {
50+
ans <-
51+
data.frame(
52+
ey_bar = c(1, NaN),
53+
err_bar = c(0, NaN),
54+
se2 = c(0, NaN),
55+
bin = c(1, 2)
56+
)
57+
val <- bin_errors(rep(1, 10), rep(0, 10), bins = 1)
58+
expect_equal(ans, val)
59+
})
60+
4961

5062
# Visual tests -----------------------------------------------------------------
5163

tests/testthat/test-ppc-test-statistics.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ test_that("ppc_stat_2d returns ggplot object", {
3939
expect_gg(ppc_stat_2d(y2, yrep2))
4040
})
4141

42+
test_that("ppc_stat_2d erros if more than 2 stats", {
43+
expect_error(ppc_stat_2d(y, yrep, stat = c("mean", "sd", "var")),
44+
"argument must have length 2")
45+
})
46+
4247
test_that("ppc_stat_grouped returns ggplot object", {
4348
expect_gg(ppc_stat_grouped(y, yrep, group))
4449
expect_gg(ppc_stat_grouped(y, yrep, as.numeric(group), stat = function(z) var(z)))

0 commit comments

Comments
 (0)