Skip to content

Commit

Permalink
Completes #870 (#871)
Browse files Browse the repository at this point in the history
Co-authored-by: Kirkpatrick <[email protected]>
  • Loading branch information
PuzzledFace-Astellas and Kirkpatrick authored Jan 14, 2025
1 parent 2e9413d commit 3934508
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/Data-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ Data <- function(x = numeric(),
assert_integerish(y, lower = 0, upper = 1, any.missing = FALSE)
assert_integerish(ID, unique = TRUE, any.missing = FALSE)
assert_integerish(cohort)
assert_numeric(doseGrid, any.missing = FALSE, unique = TRUE)
if (length(x) > 0) {
assert_numeric(doseGrid, any.missing = FALSE, unique = TRUE, min.len = 1)
} else {
assert_numeric(doseGrid, any.missing = FALSE, unique = TRUE)
}
assert_flag(placebo)

doseGrid <- sort(doseGrid)
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-Data-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,16 @@ test_that("DataGrouped default constructor works as expected", {
result <- expect_silent(.DefaultDataGrouped())
expect_valid(result, "DataGrouped")
})

test_that("Data constructor provides informative error message when doseGrid is misspelt", {
expect_error(
Data(
x = c(1, 1, 1, 2, 2, 2),
y = c(0, 0, 0, 0, 1, 0),
dataGrid = c(1, 2, 4, 8, 16, 30, 50, 100),
ID = 1L:6L,
cohort = rep(1:2, each = 3)
),
"Assertion on 'doseGrid' failed: Must have length >= 1, but has length 0."
)
})

0 comments on commit 3934508

Please sign in to comment.