[Rcpp-commits] r4042 - in pkg/Rcpp/inst/unitTests: . cpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 26 11:02:42 CET 2012


Author: romain
Date: 2012-11-26 11:02:42 +0100 (Mon, 26 Nov 2012)
New Revision: 4042

Added:
   pkg/Rcpp/inst/unitTests/cpp/
   pkg/Rcpp/inst/unitTests/cpp/reg_tests_0_10_1.cpp
   pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R
Log:
started to add some unit tests for new features in 0.10.1

Added: pkg/Rcpp/inst/unitTests/cpp/reg_tests_0_10_1.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/cpp/reg_tests_0_10_1.cpp	                        (rev 0)
+++ pkg/Rcpp/inst/unitTests/cpp/reg_tests_0_10_1.cpp	2012-11-26 10:02:42 UTC (rev 4042)
@@ -0,0 +1,13 @@
+#include <Rcpp.h>
+using namespace Rcpp ;
+
+// [[Rcpp::export]]
+int DataFrame_nrows( DataFrame df){
+    return df.nrows() ;
+}
+
+// [[Rcpp::export]]
+double RangeIndexer_sugar( NumericVector x ){
+    return max( x[ seq(0, 4) ], 5 ) ;    
+}
+

Added: pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R	                        (rev 0)
+++ pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R	2012-11-26 10:02:42 UTC (rev 4042)
@@ -0,0 +1,31 @@
+#!/usr/bin/r -t
+#
+# Copyright (C) 2012  Dirk Eddelbuettel and Romain Francois
+#
+# This file is part of Rcpp.
+#
+# Rcpp is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+.setUp <- function(){
+    sourceCpp( system.file( "unitTests/cpp/reg_tests_0_10_1.cpp" ) )   
+}
+
+test.DataFrame.nrows <- function(){
+    checkEquals( DataFrame_nrows( iris ), nrow(iris) )  
+}
+
+test.RangeIndexer <- function(){
+    x <- rnorm(10)
+    checkEquals( RangeIndexer(x), max(x[1:5]) )    
+}



More information about the Rcpp-commits mailing list