-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove comment argument from
setMaxIntakeRate()
as proposed in #214
- Loading branch information
1 parent
835c6fa
commit 084bbe8
Showing
7 changed files
with
82 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
params <- NS_params | ||
no_sp <- nrow(params@species_params) | ||
|
||
## setMaxIntakeRate ---- | ||
test_that("ssetMaxIntakeRate works", { | ||
expect_identical(setMaxIntakeRate(params, params@intake_max, | ||
comment_intake_max = NULL), params) | ||
# setMaxIntakeRate ---- | ||
test_that("setMaxIntakeRate works", { | ||
params <- NS_params | ||
params@species_params$h <- 2 * params@species_params$h | ||
p2 <- setMaxIntakeRate(params) | ||
expect_identical(2 * params@intake_max, p2@intake_max) | ||
# only intake max changed | ||
p2@intake_max <- params@intake_max | ||
expect_identical(p2, params) | ||
}) | ||
test_that("Comment works on intake_max", { | ||
params <- NS_params | ||
# if no comment, it is set automatically | ||
intake_max <- params@intake_max | ||
params <- setMaxIntakeRate(params, intake_max = intake_max) | ||
expect_identical(comment(params@intake_max), "set manually") | ||
|
||
# comment is stored | ||
comment(intake_max) <- "test" | ||
params <- setMaxIntakeRate(params, intake_max = intake_max) | ||
expect_identical(comment(params@intake_max), "test") | ||
|
||
# if no comment, previous comment is kept | ||
comment(intake_max) <- NULL | ||
params <- setMaxIntakeRate(params, intake_max = intake_max) | ||
expect_identical(comment(params@intake_max), "test") | ||
|
||
# no message when nothing changes | ||
expect_message(setMaxIntakeRate(params), NA) | ||
# but message when a change is not stored due to comment | ||
params@species_params$h <- 1 | ||
expect_message(setMaxIntakeRate(params), | ||
"has been commented") | ||
|
||
# comment argument is ignored when there is a comment on intake_max | ||
params <- setMaxIntakeRate(params, intake_max = intake_max, | ||
comment_intake_max = "overwrite") | ||
expect_identical(comment(params@intake_max), "test") | ||
# but it is used otherwise | ||
comment(intake_max) <- NULL | ||
params <- setMaxIntakeRate(params, intake_max = intake_max, | ||
comment_intake_max = "overwrite") | ||
expect_identical(comment(params@intake_max), "overwrite") | ||
expect_message(setMaxIntakeRate(params), "has been commented") | ||
# Can reset | ||
p <- setMaxIntakeRate(params, reset = TRUE) | ||
expect_equal(p@intake_max[, 1], params@w[1]^params@species_params$n, | ||
check.attributes = FALSE) | ||
expect_warning(setMaxIntakeRate(params, intake_max = intake_max, | ||
reset = TRUE), | ||
"Because you set `reset = TRUE`, the") | ||
}) | ||
|
||
# getMaxIntakeRate ---- | ||
test_that("getMaxIntakeRate works", { | ||
p <- setMaxIntakeRate(params, intake_max = getMaxIntakeRate(params), | ||
comment_intake_max = NULL) | ||
expect_identical(params, p) | ||
expect_identical(getMaxIntakeRate(NS_params), | ||
NS_params@intake_max) | ||
}) |