Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2581 - enhance test coverage: derive_var_trtemfl.R #2608

Merged
merged 8 commits into from
Dec 20, 2024
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/compute_scale.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
! Argument `target_range` is missing with no default and `source_range` is not missing.
i Either both or neither arguments should be specified.

---
# compute_scale Test 7: error if target_range is supplied, but not source_range

Code
compute_scale(input, target_range = c(0, 100), min_n = 2)
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/_snaps/derive_var_trtemfl.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@
! `intensity` argument was specified but not `initial_intensity`
Either both or none of them must be specified.

# derive_var_trtemfl Test 11: error if `group_var` without `subject_keys`

Code
derive_var_trtemfl(adae, group_var = AEGRPID, subject_keys = NULL)
Condition
Error in `derive_var_trtemfl()`:
! `group_var` argument was specified but not `subject_keys`
`subject_keys` argument must be provided when `group_var` is specified.

14 changes: 13 additions & 1 deletion tests/testthat/test-derive_var_trtemfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ test_that("derive_var_trtemfl Test 9: error if `intensity` without `initial_inte
})

## Test 10: warning if both `initial_intensity` and `group_var` are specified ----
test_that("derive_var_trtemfl Test 9: error if `intensity` without `initial_intensity`", {
test_that("derive_var_trtemfl Test 10: error if `intensity` without `initial_intensity`", {
expect_warning(
derive_var_trtemfl(
adae2,
Expand All @@ -204,3 +204,15 @@ test_that("derive_var_trtemfl Test 9: error if `intensity` without `initial_inte
"`initial_intensity` argument is ignored when `group_var` is specified"
)
})

## Test 11: error if `group_var` are specified without `subject_keys` ----
test_that("derive_var_trtemfl Test 11: error if `group_var` without `subject_keys`", {
expect_snapshot(
derive_var_trtemfl(
adae,
group_var = AEGRPID,
subject_keys = NULL
),
error = TRUE
)
})
Loading