From phgrosjean at sciviews.org  Sat Jul  4 06:07:46 2009
From: phgrosjean at sciviews.org (Philippe Grosjean)
Date: Sat, 04 Jul 2009 06:07:46 +0200
Subject: [Rd] beginner's guide to C++ programming with R packages?
In-Reply-To: <1246672391.559.12.camel@corn.betterworld.us>
References: <13e802630906261243s7b071010ldfe6416e8c0ae304@mail.gmail.com>	<8ec76080906261317g77abf908wa1b9614efd19c489@mail.gmail.com>
	<1246672391.559.12.camel@corn.betterworld.us>
Message-ID: <4A4ED592.3010404@sciviews.org>

Ross Boylan wrote:
> On Fri, 2009-06-26 at 16:17 -0400, Whit Armstrong wrote:
>>> But this draws me back to the basic question.  I don't want to run R
>>> CMD INSTALL 20 times per hour.  How do developers "actually" test
>>> their code?
>> check out RUnit for tests.
>> http://cran.r-project.org/web/packages/RUnit/index.html

You could also look at the svUnit package 
http://cran.r-project.org/web/packages/svUnit/index.html
.

PhG

>> as for testing c++ code.  I have taken an approach which is probably
>> different than most.  I try to build my package as a c++ library that
>> can be used independent of R.  Then you can test your library with
>> whatever c++ test suite that you prefer.  Once you are happy, then
> I also have C++ tests that operate separately from R, though I have a
> very small library of stub R functions to get the thing to build.  There
> have been some tricky issues with R (if one links to the regular R
> library) and the test framework fighting over who was "main."  I think
> that's why I switched to the stub.
> 
> Working only with R level tests alone does not permit the kind of lower
> level testing that you can get by running your own unit tests.  I use
> the boost unit test framework.
> 
> Of course, you want R level tests too.  Some of my upper level C++ tests
> are mirror images of R tests; this can help identify if a problem lies
> at the interface.
> 
> For C++ tests I build my code in conjunction with a main program.
> 
> I think I also have or had a test building it as a library, but I don't
> use that much.
> 
> For R, my modules get built into a library.
> 
> It's usually cleaner to build the R library from a fresh version of the
> sources; otherwise scraps of my other builds tend to end up in the R
> package.
> 
> Thanks, Whit, for the  pointers to Rcpp and RAbstraction.
> Ross Boylan
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
>



[Rd] beginner's guide to C++ programming with R packages?
Philippe Grosjean