Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# admiralneuro (development version)

## Updates of Existing Functions

- Improved test coverage in `compute_centiloid()` function when invalid tracer combination is provided. (#106)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Improved test coverage in `compute_centiloid()` function when invalid tracer combination is provided. (#106)
- Improved test coverage in `compute_centiloid()` function when invalid tracer combination is provided. (#106)

## New features

## Documentation
Expand Down
7 changes: 6 additions & 1 deletion R/compute_centiloid.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#'
#' @param suvr SUVR value
#'
#' A numeric value is expected.
#' A positive numeric value is expected.
#'
#' @permitted [num_scalar]
#'
Expand Down Expand Up @@ -136,6 +136,11 @@ compute_centiloid <- function(
custom_slope = NULL,
custom_intercept = NULL
) {
# Validation check SUVR must be positive
if (suvr <= 0) {
cli::cli_abort("{.arg suvr} must be a positive numeric value (received {.val {suvr}}).")
}

# Check custom_slope and custom_intercept
has_custom_slope <- !is.null(custom_slope)
has_custom_intercept <- !is.null(custom_intercept)
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/_snaps/compute_centiloid.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,18 @@

Argument `custom_intercept` must be a numeric vector, but it is a string.

# Test 15 compute_centiloid() throws the expected error message when non-valid combination for conversion formula is used

No standard conversion formula available for:
* tracer = "18F-Florbetapir"
* pipeline = "AVID FBB SUVR PIPELINE"
* ref_region = "Whole Cerebellum"

# Test 16 compute_centiloid throws error for non-positive SUVR values

`suvr` must be a positive numeric value (received 0).

---

`suvr` must be a positive numeric value (received -1.5).

33 changes: 33 additions & 0 deletions tests/testthat/test-compute_centiloid.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,36 @@ test_that("Test 14: Custom parameters non numeric inputs trigger error", {
)
)
})

test_that("Test 15 compute_centiloid() throws the expected error message when non-valid combination for conversion formula is used", { # nolint
expect_snapshot_error(
compute_centiloid(
tracer = "18F-Florbetapir",
pipeline = "AVID FBB SUVR PIPELINE",
ref_region = "Whole Cerebellum",
suvr = 1.25
)
)
})

test_that("Test 16 compute_centiloid throws error for non-positive SUVR values", {
# Test with zero
expect_snapshot_error(
compute_centiloid(
tracer = "18F-Florbetapir",
pipeline = "AVID FBP SUVR PIPELINE",
ref_region = "Whole Cerebellum",
suvr = 0
)
)

# Test with negative value
expect_snapshot_error(
compute_centiloid(
tracer = "18F-Florbetapir",
pipeline = "AVID FBP SUVR PIPELINE",
ref_region = "Whole Cerebellum",
suvr = -1.5
)
)
})
Loading