From 5fb4e4a1777918ea6ea96493665dc12d2f66c14d Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Thu, 15 Aug 2024 12:01:32 +0200 Subject: [PATCH] Added unit tests for `func_MCMC_graph()` (#11) --- tests/testthat/test-func_MCMC_graph_cpp.R | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/testthat/test-func_MCMC_graph_cpp.R b/tests/testthat/test-func_MCMC_graph_cpp.R index 63e7e9a..509f82a 100644 --- a/tests/testthat/test-func_MCMC_graph_cpp.R +++ b/tests/testthat/test-func_MCMC_graph_cpp.R @@ -38,3 +38,11 @@ BayesSurvive_wrap <- function(use_cpp = FALSE) { } fit_R <- BayesSurvive_wrap(use_cpp = FALSE) fit_C <- BayesSurvive_wrap(use_cpp = TRUE) + +test_that("R and C++ objects are similar", { + expect_equal(fit_R$call, fit_C$call) + expect_equal(fit_R$input, fit_C$input) + for (obj in names(fit_R$output)[2]) { + expect_equal(fit_R$output[[obj]], fit_C$output[[obj]], tolerance = 1) + } +})