Skip to content

Commit

Permalink
Closes #2581 - enhance test coverage: derive_var_trtemfl.R (#2608)
Browse files Browse the repository at this point in the history
* 2581 - enhance test coverage: derive_var_trtemfl.R

* 2581 fix styler error

* 2521 - typo in Test #10 for derive_var_trtemfl

* # 2581 Test #9, fix typo

* 2581 derive_var_trtemfl() - correct Test 11 to use `expect_snapshot` so exact error msg is caught

---------

Co-authored-by: Stefan Bundfuss <[email protected]>
  • Loading branch information
jimrothstein and bundfussr authored Dec 20, 2024
1 parent f9f0492 commit 982faf8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
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
)
})

0 comments on commit 982faf8

Please sign in to comment.