Skip to content

Commit

Permalink
test fixes and expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Sep 11, 2024
1 parent ef3fc43 commit a3b25e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/utilc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down
15 changes: 9 additions & 6 deletions tests/testthat/test-logit.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})

Expand Down Expand Up @@ -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))
})
})
2 changes: 1 addition & 1 deletion tests/testthat/test-rxUiDeparse.R
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"))

})

0 comments on commit a3b25e4

Please sign in to comment.