Skip to content

Commit

Permalink
Closes #2577: Add unit tests for set_admiral_options (#2589)
Browse files Browse the repository at this point in the history
* Test signif digits is positive and setter works

* Update test descriptions

---------

Co-authored-by: Edoardo Mancini <[email protected]>
Co-authored-by: Ben Straub <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2024
1 parent a92dd68 commit 4dfaa3b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/testthat/test-admiral_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test_that("get_admiral_option Test 3: non-character argument triggers assertion
})

# set_admiral_options ----
## Test 4: set works ----
## Test 4: set subject_keys works ----
test_that("set_admiral_options Test 4: set works", {
set_admiral_options(subject_keys = exprs(STUDYID, USUBJID2))
expect_equal(get_admiral_option("subject_keys"), exprs(STUDYID, USUBJID2))
Expand All @@ -35,4 +35,26 @@ test_that("set_admiral_options Test 5: unexpected function input for set gives e
class = "assert-admiraldev"
)
})

## Test 6: non-positive numeric argument triggers assertion error ----
test_that("get_admiral_option Test 6: non-positive numeric argument triggers assertion error", {
sigfigs <- 0
expect_error(
set_admiral_options(signif_digits = sigfigs),
class = "assert_integer_scalar"
)
sigfigs <- -1
expect_error(
set_admiral_options(signif_digits = sigfigs),
class = "assert_integer_scalar"
)
})

## Test 7: set signif_digits works ----
test_that("set_admiral_options Test 7: set works", {
sigfigs <- get_admiral_option("signif_digits")
set_admiral_options(signif_digits = sigfigs + 1)
expect_equal(get_admiral_option("signif_digits"), sigfigs + 1)
set_admiral_options(signif_digits = sigfigs)
})
set_admiral_options(subject_keys = exprs(STUDYID, USUBJID))

0 comments on commit 4dfaa3b

Please sign in to comment.