Unit testing Rcpp code in a package

I have C ++ code in a package that I want to unit test and I don't want to export it to R. I saw:

Unit tests for code in / src folder of R package?

and the code I want to test falls into the second category:

Or you think your C code is more self-contained, in which case you can use one of the basic bazillion testing units for C.

If you want to test C ++ (not using the R framework), what's the best way to install a test suite? Put your C ++ tests in tests/

and then you have a C ++ program somewhere, or are you writing a driver function to execute all C ++ tests and then call it from R?

I think it probably would be nice to automate tests with R CMD check

, and I don't understand how to automate using the R framework.


source to share

1 answer

I am not following:

  • Either it's Rcpp code, but you don't want to expose it to R: the moment you try to expose it to the (R) unit tests (in the packaging structure) that you do.
  • Or is it just a matter of choosing one of the (very many) C ++ unit testing units like Boost Test , or Google's C ++ Testing library or ... --- none of which has been ported to R "as such"

Can you clarify your question a little more?

Perhaps you just want to express your C ++ code in such a way that Rcpp only calls it from unit tests to get results, which you can then test through one of the popular R test frameworks. In this case, the answer might be very similar to what any of the (currently) 276 Rcpp-used packages on CRAN do as many do in fact use unit tests.



All Articles