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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 4 00:25:43 CEST 2010


Author: edd
Date: 2010-05-04 00:25:43 +0200 (Tue, 04 May 2010)
New Revision: 1147

Added:
   pkg/Rcpp/inst/unitTests/runit.DataFrame.R
Modified:
   pkg/Rcpp/inst/ChangeLog
Log:
added DataFrame unit tests
minor reformat to 80 cols for ChangeLog


Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-05-03 19:57:06 UTC (rev 1146)
+++ pkg/Rcpp/inst/ChangeLog	2010-05-03 22:25:43 UTC (rev 1147)
@@ -1,39 +1,43 @@
-2010-05-03	Romain Francois <romain at r-enthusiasts.com>
+2010-05-03  Dirk Eddelbuettel  <edd at dexter>
 
-	* inst/include/Rcpp/exceptions.h : move the what methods of exception 
-	classes so that the symbol is defined for sure in the shared library. This
-	seems to make a difference dur to vague linkage issues. decrypted from
-	http://gcc.gnu.org/wiki/Visibility
+	* inst/unitTests/runit.DataFrame.R: unit tests for Rcpp::DataFrame
 
-2010-05-02	Romain Francois <romain at r-enthusiasts.com>
+2010-05-03  Romain Francois <romain at r-enthusiasts.com>
 
+	* inst/include/Rcpp/exceptions.h : move the what methods of exception
+	classes so that the symbol is defined for sure in the shared
+	library. This seems to make a difference due to vague linkage
+	issues. Decrypted from http://gcc.gnu.org/wiki/Visibility
+
+2010-05-02  Romain Francois <romain at r-enthusiasts.com>
+
 	* inst/include/Rcpp/as.h: add throw(not_compatible) in Rcpp::as
 
-	* inst/include/Rcpp/clone.h: the clone(SEXP) moves to the headers	
+	* inst/include/Rcpp/clone.h: the clone(SEXP) moves to the headers
 
-2010-04-28	Romain Francois <romain at r-enthusiasts.com>
+2010-04-28  Romain Francois <romain at r-enthusiasts.com>
 
 	* inst/include/Rcpp/Vector.h: changed Vector( size_t ) to Vector( int )
 	to allow Vector( 0 ) and Vector::create()
 
-2010-04-27	Romain Francois <romain at r-enthusiasts.com>
+2010-04-27  Romain Francois <romain at r-enthusiasts.com>
 
-	* inst/include/Rcpp/preprocessor.h: new macro RCPP_ENUM_TRAITS to 
-	generate traits needed to support wrap for an enum type (used in 
+	* inst/include/Rcpp/preprocessor.h: new macro RCPP_ENUM_TRAITS to
+	generate traits needed to support wrap for an enum type (used in
 	RProtoBuf)
-	
-	* R/Rcpp.package.skeleton.R: correctly handle the example_code argument
 
-2010-04-26	Romain Francois <romain at r-enthusiasts.com>
+	* R/Rcpp.package.skeleton.R: correctly handle the example_code
+	argument
 
+2010-04-26  Romain Francois <romain at r-enthusiasts.com>
+
 	* inst/include/Rcpp/DataFrame_*.h: new class Rcpp::DataFrame
-	
+
 	* inst/include/Rcpp/preprocessor.h: added RCPP_XP_FIELD macro
-	
+
 	* inst/include/Rcpp/preprocessor_generated.h: added the set of macros
-	RCPP_WRAPPER_0, ..., RCPP_WRAPPER_65 to help wrapping existing 
+	RCPP_WRAPPER_0, ..., RCPP_WRAPPER_65 to help wrapping existing
 	C functions into .Call callables functions
-	
 
 2010-04-16  Dirk Eddelbuettel  <edd at debian.org>
 

Added: pkg/Rcpp/inst/unitTests/runit.DataFrame.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.DataFrame.R	                        (rev 0)
+++ pkg/Rcpp/inst/unitTests/runit.DataFrame.R	2010-05-03 22:25:43 UTC (rev 1147)
@@ -0,0 +1,49 @@
+#!/usr/bin/r -t
+#
+# Copyright (C) 2010	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/>.
+
+runit.DataFrame.FromSEXP <- function() {
+    DF <- data.frame(a=1:3, b=c("a","b","c"))
+	fun <- cppfunction( signature(x='ANY'), '
+		DataFrame df(x) ;
+		return df;
+	' )
+	checkEquals( fun(DF), DF, msg = "DataFrame pass-through")
+}
+
+runit.DataFrame.create1 <- function() {
+    DF <- data.frame(a=1:3)
+	fun <- cppfunction( signature(), '
+        IntegerVector v = IntegerVector::create(1,2,3);
+		return DataFrame::create(Named("a")=v);
+	' )
+	checkEquals( fun(), DF, msg = "DataFrame create1")
+}
+
+runit.DataFrame.create2 <- function() {
+    DF <- data.frame(a=1:3, b=c("a","b","c"))
+	fun <- cppfunction( signature(), '
+        IntegerVector v = IntegerVector::create(1,2,3);
+        std::vector<std::string> s(3);
+        s[0] = "a";
+        s[1] = "b";
+        s[2] = "c";
+		return DataFrame::create(Named("a")=v, Named("b")=s);
+	' )
+	checkEquals( fun(), DF, msg = "DataFrame create2")
+}



More information about the Rcpp-commits mailing list