From a3b25e464979eb98121581265e616b000826f729 Mon Sep 17 00:00:00 2001 From: Matthew Fidler Date: Wed, 11 Sep 2024 09:30:57 -0500 Subject: [PATCH] test fixes and expansion --- src/utilc.c | 6 ++++++ tests/testthat/test-logit.R | 15 +++++++++------ tests/testthat/test-rxUiDeparse.R | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/utilc.c b/src/utilc.c index 80851462b..c9e2c7364 100644 --- a/src/utilc.c +++ b/src/utilc.c @@ -604,6 +604,12 @@ SEXP _rxode2_powerD(SEXP xS, SEXP lowS, SEXP highS, SEXP lambdaS, SEXP yjS, SEXP int inverse = INTEGER(inverseS)[0]; int yj = INTEGER(yjS)[0]; double low, high, lambda; + if (Rf_length(inverseS) != 1) { + Rf_errorcall(R_NilValue, _("'inverse' must be an logical of length 1")); + } + if (Rf_length(yjS) != 1) { + Rf_errorcall(R_NilValue, _("'yj' must be an integer of length 1")); + } if (Rf_length(lambdaS) != 1){ Rf_errorcall(R_NilValue, _("'lambda' must be a numeric of length 1")); } diff --git a/tests/testthat/test-logit.R b/tests/testthat/test-logit.R index 50ed3f0b8..0b3573985 100644 --- a/tests/testthat/test-logit.R +++ b/tests/testthat/test-logit.R @@ -51,8 +51,15 @@ rxTest({ expect_equal(logit(1:10, 0L, 11L), logit(as.double(1:10), 0.0, 11.0)) - expect_error(logit(0.5, c(1, 2))) - expect_error(logit(0.5, 0, c(1, 2))) + expect_equal(logit(7, c(1, 2), c(10, 114)), + c(logit(7, 1, 10), + logit(7, 2, 114))) + + expect_error(.Call(`_rxode2_powerD`, 0.5, c(1, 2), 3, 4, 4L, TRUE)) + expect_error(.Call(`_rxode2_powerD`, 0.5, 1, c(3, 4), 4, 4L, TRUE)) + expect_error(.Call(`_rxode2_powerD`, 0.5, 1, 3, 4, c(4L, 5L), TRUE)) + expect_error(.Call(`_rxode2_powerD`, 0.5, 1, 3, 4, 4L, c(TRUE, FALSE))) + expect_error(logit(0.5, 1, -2)) }) @@ -107,9 +114,5 @@ rxTest({ ) expect_equal(expit(1:10, 0L, 11L), expit(as.double(1:10), 0.0, 11.0)) - - expect_error(expit(0.5, c(1, 2))) - expect_error(expit(0.5, 0, c(1, 2))) - expect_error(expit(0.5, 1, -2)) }) }) diff --git a/tests/testthat/test-rxUiDeparse.R b/tests/testthat/test-rxUiDeparse.R index cc005bf25..284384511 100644 --- a/tests/testthat/test-rxUiDeparse.R +++ b/tests/testthat/test-rxUiDeparse.R @@ -8,6 +8,6 @@ test_that("rxUiDeparse()", { naInterpolation="nocb", keepInterpolation="nocb", sigmaXform="variance", omegaXform="variance", returnType="data.frame", sumType="fsum", prodType="logify", sensType="central"), "a"), - str2lang("a <- rxControl(method = \"dop853\", covsInterpolation = \"linear\", returnType = \"data.frame\", sigmaXform = \"variance\", sumType = \"fsum\", prodType = c(\"long double\", \"double\", \"logify\"), sensType = \"central\", naInterpolation = \"nocb\", keepInterpolation = \"nocb\")")) + str2lang("a <- rxControl(method = \"dop853\", covsInterpolation = \"linear\", returnType = \"data.frame\", sigmaXform = \"variance\", sumType = \"fsum\", sensType = \"central\", naInterpolation = \"nocb\", keepInterpolation = \"nocb\")")) })