Skip to content

Commit 0f72378

Browse files
committed
Moved unit tests for "ppc-censoring" to their own file.
1 parent 81b4dfe commit 0f72378

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

tests/testthat/test-ppc-censoring.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
library(bayesplot)
2+
context("PPC: censoring")
3+
4+
source(test_path("data-for-ppc-tests.R"))
5+
6+
test_that("ppc_km_overlay returns a ggplot object", {
7+
expect_gg(ppc_km_overlay(y, yrep, status_y = status_y, size = 0.5, alpha = 0.2))
8+
expect_gg(ppc_km_overlay(y2, yrep2, status_y = status_y2))
9+
})
10+
11+
# Visual tests -----------------------------------------------------------------
12+
13+
test_that("ppc_km_overlay renders correctly", {
14+
testthat::skip_on_cran()
15+
testthat::skip_if_not_installed("vdiffr")
16+
17+
p_base <- ppc_km_overlay(vdiff_y2, vdiff_yrep2, status_y = vdiff_status_y2)
18+
vdiffr::expect_doppelganger("ppc_km_overlay (default)", p_base)
19+
20+
p_custom <- ppc_km_overlay(
21+
vdiff_y2,
22+
vdiff_yrep2,
23+
status_y = vdiff_status_y2,
24+
size = 2,
25+
alpha = .2)
26+
vdiffr::expect_doppelganger("ppc_km_overlay (size, alpha)", p_custom)
27+
})

tests/testthat/test-ppc-distributions.R

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ test_that("ppc_ecdf_overlay returns a ggplot object", {
1313
expect_gg(ppc_ecdf_overlay(y2, yrep2))
1414
})
1515

16-
test_that("ppc_km_overlay returns a ggplot object", {
17-
expect_gg(ppc_km_overlay(y, yrep, status_y = status_y, size = 0.5, alpha = 0.2))
18-
expect_gg(ppc_km_overlay(y2, yrep2, status_y = status_y2))
19-
})
20-
2116
test_that("ppc_dens,pp_hist,ppc_freqpoly,ppc_boxplot return ggplot objects", {
2217
expect_gg(ppc_hist(y, yrep[1,, drop = FALSE]))
2318
expect_gg(ppc_hist(y, yrep[1:8, ]))
@@ -152,22 +147,6 @@ test_that("ppc_ecdf_overlay_grouped renders correctly", {
152147
)
153148
})
154149

155-
test_that("ppc_km_overlay renders correctly", {
156-
testthat::skip_on_cran()
157-
testthat::skip_if_not_installed("vdiffr")
158-
159-
p_base <- ppc_km_overlay(vdiff_y2, vdiff_yrep2, status_y = vdiff_status_y2)
160-
vdiffr::expect_doppelganger("ppc_km_overlay (default)", p_base)
161-
162-
p_custom <- ppc_km_overlay(
163-
vdiff_y2,
164-
vdiff_yrep2,
165-
status_y = vdiff_status_y2,
166-
size = 2,
167-
alpha = .2)
168-
vdiffr::expect_doppelganger("ppc_km_overlay (size, alpha)", p_custom)
169-
})
170-
171150
test_that("ppc_dens renders correctly", {
172151
testthat::skip_on_cran()
173152
testthat::skip_if_not_installed("vdiffr")

0 commit comments

Comments
 (0)