Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShixiangWang committed Sep 11, 2021
1 parent 514b0f6 commit a173442
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 22 deletions.
6 changes: 5 additions & 1 deletion R/clean_model_dir.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
#' @export
#'
#' @examples
#' clean_model_dir
#' \donttest{
#' clean_model_dir()
#' }
#' @testexamples
#' expect_message(clean_model_dir(), "Done")
clean_model_dir <- function(model_dir = file.path(tempdir(), "ezcox")) {
if (dir.exists(model_dir)) {
message("Cleaning...")
Expand Down
5 changes: 4 additions & 1 deletion R/show_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
#' covariates = c("sex", "ph.ecog"), controls = "age", merge_models = TRUE,
#' drop_controls = TRUE
#' )
#' show_forest(lung,
#' p <- show_forest(lung,
#' covariates = c("sex", "ph.ecog"), controls = "age", merge_models = TRUE,
#' vars_to_show = "sex"
#' )
#' p
#' @testexamples
#' expect_s3_class(p, "ggplot")
show_forest <- function(data, covariates, controls = NULL,
time = "time",
status = "status",
Expand Down
Binary file modified docs/reference/Rplot001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/Rplot002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/Rplot003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/Rplot004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 4 additions & 14 deletions docs/reference/clean_model_dir.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/show_forest-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/show_forest-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/show_forest-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions docs/reference/show_forest.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/clean_model_dir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/show_forest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/testthat/test-roxytest-testexamples-clean_model_dir.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated by roxytest: Do not edit by hand!

# File R/clean_model_dir.R: @testexamples

test_that("Function clean_model_dir() @ L14", {


clean_model_dir()

expect_message(clean_model_dir(), "Done")
})

21 changes: 21 additions & 0 deletions tests/testthat/test-roxytest-testexamples-show_forest.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by roxytest: Do not edit by hand!

# File R/show_forest.R: @testexamples

test_that("Function show_forest() @ L36", {

library(survival)
show_forest(lung, covariates = c("sex", "ph.ecog"), controls = "age")
show_forest(lung, covariates = c("sex", "ph.ecog"), controls = "age", merge_models = TRUE)
show_forest(lung,
covariates = c("sex", "ph.ecog"), controls = "age", merge_models = TRUE,
drop_controls = TRUE
)
p <- show_forest(lung,
covariates = c("sex", "ph.ecog"), controls = "age", merge_models = TRUE,
vars_to_show = "sex"
)
p
expect_s3_class(p, "ggplot")
})

0 comments on commit a173442

Please sign in to comment.