From 4dfaa3b1e4dd3af2b021456e62bbec11526f63bb Mon Sep 17 00:00:00 2001 From: Anthogonyst <33465817+Anthogonyst@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:55:24 -0500 Subject: [PATCH] Closes #2577: Add unit tests for set_admiral_options (#2589) * Test signif digits is positive and setter works * Update test descriptions --------- Co-authored-by: Edoardo Mancini <53403957+manciniedoardo@users.noreply.github.com> Co-authored-by: Ben Straub --- tests/testthat/test-admiral_options.R | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-admiral_options.R b/tests/testthat/test-admiral_options.R index 241459d9a0..c89050f158 100644 --- a/tests/testthat/test-admiral_options.R +++ b/tests/testthat/test-admiral_options.R @@ -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)) @@ -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))