From 3802b6f9f587622a9e0f20c8cd2633b8f3814022 Mon Sep 17 00:00:00 2001 From: Ron Keizer Date: Fri, 5 Jul 2024 18:04:53 +0000 Subject: [PATCH] add test --- tests/testthat/test_regimen_to_nm.R | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test_regimen_to_nm.R b/tests/testthat/test_regimen_to_nm.R index 159fefb..6f37b0a 100644 --- a/tests/testthat/test_regimen_to_nm.R +++ b/tests/testthat/test_regimen_to_nm.R @@ -33,7 +33,7 @@ test_that("regimen with infusion correctly recalculates rates when bioavailabili t_obs = c(1, 2, 3), bioav = "F1" ), - "Bioavailability not specified correctly" + "For compartments where bioavailability is specified" ) expected_cols <- c( "ID", @@ -95,3 +95,34 @@ test_that("rate is calculated for any regimen with an infusion length", { expect_equal(c$RATE, c(0, 0, 0, 0, 0, 10, 20, 0)) }) +test_that("throws warning when bioav specified as model parameter and need to convert RATE, but not when not needed", { + a <- new_regimen( + amt = 10, + time = c(1, 2, 3, 4), + t_inf = c(0, 0, 1, 1), + type = c("oral", "oral", "infusion", "infusion") + ) + expect_message({ + b <- regimen_to_nm( + a, + dose_cmt = c(1, 1, 2, 2), + t_obs = c(1, 2, 3), + bioav = c("Fi", 1) + ) + }, "Recalculating infusion rates") + a2 <- new_regimen( + amt = 10, + time = c(1, 2, 3, 4), + t_inf = c(1, 1, 1, 1), # now an infusion in the sc compartment and infusion lengths are >0, should throw warning! + type = c("sc", "sc", "infusion", "infusion") + ) + expect_warning( + regimen_to_nm( + a2, + dose_cmt = c(1, 1, 2, 2), + t_obs = c(1, 2, 3), + bioav = c("Fi", 1) + ), + "For compartments where bioavailability is specified" + ) +})