Skip to content

Commit

Permalink
Extra tests for #55
Browse files Browse the repository at this point in the history
  • Loading branch information
ellessenne committed Dec 12, 2023
1 parent df6647c commit 62ff4c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions R/autoplot.simsum.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ autoplot.simsum <- function(object, type = "forest", stats = "nsim", target = NU
if (type %in% c("zip", "est", "se", "est_ba", "se_ba", "est_ridge", "se_ridge", "est_density", "se_density", "est_hex", "se_hex")) {
checkmate::assert_true(x = !is.null(object$x), add = arg_checks)
}
# zip_ci_colours must be a string
checkmate::assert_character(x = zip_ci_colours, min.len = 1, max.len = 3)
# Report
if (!arg_checks$isEmpty()) checkmate::reportAssertions(arg_checks)

Expand Down
2 changes: 1 addition & 1 deletion testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ ms <- multisimsum(
x = TRUE
)
ms
autoplot(ms, par = "trt", type = "zip", zip_ci_colours = c("green", "red"))
autoplot(ms, par = "trt", type = "zip", zip_ci_colours = c("green", "red", "yellow"))
12 changes: 12 additions & 0 deletions tests/testthat/test-#55.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testthat::test_that("#55", {
data("tt", package = "rsimsum")

s <- simsum(data = tt, estvarname = "diff", se = "se", true = -1, x = TRUE)
testthat::expect_s3_class(object = autoplot(s, type = "zip"), class = c("gg", "ggplot"))
testthat::expect_s3_class(object = autoplot(s, type = "zip", zip_ci_colours = "blue"), class = c("gg", "ggplot"))
testthat::expect_s3_class(object = autoplot(s, type = "zip", zip_ci_colours = c("green", "red")), class = c("gg", "ggplot"))
testthat::expect_s3_class(object = autoplot(s, type = "zip", zip_ci_colours = c("green", "red", "blue")), class = c("gg", "ggplot"))
testthat::expect_error(object = autoplot(s, type = "zip", zip_ci_colours = c("green", "red", "blue", "yellow")))
testthat::expect_error(object = autoplot(s, type = "zip", zip_ci_colours = 1))
testthat::expect_error(object = autoplot(s, type = "zip", zip_ci_colours = TRUE))
})

0 comments on commit 62ff4c5

Please sign in to comment.