Skip to content

Commit

Permalink
Add behavior tests for iCov
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Aug 2, 2024
1 parent 89ac0a4 commit 36f8a06
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tests/testthat/test-iCov.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ rxTest({
expect_error(etTrans(ev, mod1, iCov=paramsDf2),
"the 'id' in the iCov must have 1 unique match to the event table")

# Now check for proper behavior

tmp <- etTrans(ev, mod1, iCov=paramsDf)
tmp2 <- attr(class(tmp), ".rxode2.lst")
class(tmp2) <- NULL

for (v in c("EC50", "Kout", "Kin", "V3", "Q", "V2", "CL", "KA")) {
expect_equal(tmp2$cov1[[v]], paramsDf[[v]])
expect_equal(tmp2$pars[v,], paramsDf[[v]])
}

# Check keep of various sorts in iCov
tmp <- rxSolve(mod1, ev, iCov=paramsDf, keep=c("CL", "V2", "ptS", "ptF", "ptI", "ptL"))
expect_true(is.character(tmp$ptS))
Expand All @@ -131,11 +142,9 @@ rxTest({
for (v in
c("evid", "time", "amt", "value", "cmt", "ytype", "state", "var", "dv",
"rate","dur", "addl", "ii", "mdv", "cens", "limit", "method")) {
test_that(paste0("iCov error on '", v, "'"), {
names(paramsDf)[9] <- v
expect_error(etTrans(ev, mod1, iCov=paramsDf),
paste0("cannot specify '", v,"' in 'iCov'"))
})
names(paramsDf)[9] <- v
expect_error(etTrans(ev, mod1, iCov=paramsDf),
paste0("cannot specify '", v,"' in 'iCov'"))
}

})
Expand Down

0 comments on commit 36f8a06

Please sign in to comment.