Skip to content

Commit

Permalink
Add test for inline code
Browse files Browse the repository at this point in the history
  • Loading branch information
mclements committed May 22, 2024
1 parent 94f2346 commit a720bb6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/testthat/test-inline.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
context("inline unit tests")
library("Rcpp")

# Partitioned survival fits ---------------------------------------------------
test_that("Show that inline works for a simple example ", {
sourceCpp(code="
// [[Rcpp::depends(hesim)]]
// [[Rcpp::depends(RcppArmadillo)]]
#include <hesim.h>
// [[Rcpp::export]]
double test_inline_gengamma(double mu, double sigma, double Q) {
hesim::stats::gengamma gg(mu, sigma, Q);
return gg.random();
}")
set.seed(12345)
expect_true(abs(test_inline_gengamma(1.0, 1.0, 1.0) - 2.717582) < 1e-5)
})

0 comments on commit a720bb6

Please sign in to comment.