Skip to content

Commit

Permalink
Merge pull request #243 from mrc-ide/drug_list_check
Browse files Browse the repository at this point in the history
Check drug inputs are a list
  • Loading branch information
giovannic authored Jun 2, 2023
2 parents c9aa9d7 + b8ac7fb commit 5a81b0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/drug_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SP_AQ_params <- c(0.9, 0.32, 4.3, 38.1)
#' @param drugs a list of drug parameters, can be set using presets
#' @export
set_drugs <- function(parameters, drugs) {
stopifnot(is.list(drugs))
keys <- c(
'drug_efficacy',
'drug_rel_c',
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-treatment.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,12 @@ test_that('You cannot set invalid coverages', {
)
)
})

test_that('set_drugs errors if a list is not provided', {
parameters <- get_parameters()
expect_error(
set_drugs(parameters, AL_params),
"is.list(drugs) is not TRUE",
fixed = TRUE
)
})

0 comments on commit 5a81b0b

Please sign in to comment.