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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 15 21:42:23 CEST 2013


Author: edd
Date: 2013-09-15 21:42:23 +0200 (Sun, 15 Sep 2013)
New Revision: 4488

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/unitTests/cpp/Vector.cpp
   pkg/Rcpp/inst/unitTests/runit.Vector.R
Log:
new tests for std::vector<double> and std::vector<int> conversions


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-09-15 13:01:18 UTC (rev 4487)
+++ pkg/Rcpp/ChangeLog	2013-09-15 19:42:23 UTC (rev 4488)
@@ -1,12 +1,18 @@
-2013-09-15 Romain Francois <romain at r-enthusiasts.com>
-        
-	* include/Rcpp/InputParameter.h : added the traits::input_parameter trait
-	to add another layer of abstration. 
-	* include/Rcpp/macros/module.h : taking advantage of input_parameter to
-	specialize how to work with module objects
-	* src/attributes.cpp : using traits::input_parameter<T> instead of 
+2013-09-15  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/unitTests/cpp/Vector.cpp: New unit tests for std::vector
+	conversions, using both int and double arguments
+	* inst/unitTests/runit.Vector.R: R complement of these tests
+
+2013-09-15  Romain Francois <romain at r-enthusiasts.com>
+
+	* include/Rcpp/InputParameter.h : added the traits::input_parameter
+	trait to add another layer of abstration.
+	* include/Rcpp/macros/module.h : taking advantage of input_parameter
+	to specialize how to work with module objects
+	* src/attributes.cpp : using traits::input_parameter<T> instead of
 	InputParameter<T>
-        
+
 2013-09-14  Dirk Eddelbuettel  <edd at debian.org>
 
 	* src/attributes.cpp : Precede closing '>' by space to avoid '>>'

Modified: pkg/Rcpp/inst/unitTests/cpp/Vector.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/cpp/Vector.cpp	2013-09-15 13:01:18 UTC (rev 4487)
+++ pkg/Rcpp/inst/unitTests/cpp/Vector.cpp	2013-09-15 19:42:23 UTC (rev 4488)
@@ -729,3 +729,42 @@
 	}
 #endif
 
+// [[Rcpp::export]]
+int stdVectorDouble(std::vector<double> x) { 
+    return x.size();
+}
+
+// [[Rcpp::export]]
+int stdVectorDoubleConst(const std::vector<double> x) { 
+    return x.size();
+}
+
+// [[Rcpp::export]]
+int stdVectorDoubleRef(std::vector<double> & x) { 
+    return x.size();
+}
+
+// [[Rcpp::export]]
+int stdVectorDoubleConstRef(const std::vector<double> & x) { 
+    return x.size();
+}
+
+// [[Rcpp::export]]
+int stdVectorInt(std::vector<int> x) { 
+    return x.size();
+}
+
+// [[Rcpp::export]]
+int stdVectorIntConst(const std::vector<int> x) { 
+    return x.size();
+}
+
+// [[Rcpp::export]]
+int stdVectorIntRef(std::vector<int> & x) { 
+    return x.size();
+}
+
+// [[Rcpp::export]]
+int stdVectorIntConstRef(const std::vector<int> & x) { 
+    return x.size();
+}

Modified: pkg/Rcpp/inst/unitTests/runit.Vector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Vector.R	2013-09-15 13:01:18 UTC (rev 4487)
+++ pkg/Rcpp/inst/unitTests/runit.Vector.R	2013-09-15 19:42:23 UTC (rev 4488)
@@ -589,9 +589,9 @@
 
 test.CharacterVector.equality.operator <- function(){
     res <- CharacterVectorEqualityOperator( letters, letters )
-    checkEquals( res, 
-        list( rep( TRUE, 26L ), rep( FALSE, 26L) ), 
-        msg = 'CharacterVector element equality operator' )    
+    checkEquals( res,
+        list( rep( TRUE, 26L ), rep( FALSE, 26L) ),
+        msg = 'CharacterVector element equality operator' )
 }
 
 test.List.rep.ctor <- function(){
@@ -640,3 +640,53 @@
 }
 
 }
+
+test.std.vector.double <- function() {
+    fun <- stdVectorDouble
+    x <- seq(1.0, 5.0, by=1.0)
+    checkEquals(fun(x), 5, msg = "automatic conversion of stdVectorDouble")
+}
+
+test.std.vector.double.const <- function() {
+    fun <- stdVectorDoubleConst
+    x <- seq(1.0, 5.0, by=1.0)
+    checkEquals(fun(x), 5, msg = "automatic conversion of stdVectorDoubleConst")
+}
+
+test.std.vector.double.ref <- function() {
+    fun <- stdVectorDoubleRef
+    x <- seq(1.0, 5.0, by=1.0)
+    checkEquals(fun(x), 5, msg = "automatic conversion of stdVectorDoubleRef")
+}
+
+test.std.vector.double.const.ref <- function() {
+    fun <- stdVectorDoubleConstRef
+    x <- seq(1.0, 5.0, by=1.0)
+    checkEquals(fun(x), 5, msg = "automatic conversion of stdVectorDoubleConstRef")
+}
+
+test.std.vector.int <- function() {
+    fun <- stdVectorInt
+    x <- seq(1L, 5L, by=1L)
+    checkEquals(fun(x), 5, msg = "automatic conversion of stdVectorInt")
+}
+
+test.std.vector.int.const <- function() {
+    fun <- stdVectorIntConst
+    x <- seq(1L, 5L, by=1L)
+    checkEquals(fun(x), 5, msg = "automatic conversion of stdVectorIntConst")
+}
+
+test.std.vector.int.ref <- function() {
+    fun <- stdVectorIntRef
+    x <- seq(1L, 5L, by=1L)
+    checkEquals(fun(x), 5, msg = "automatic conversion of stdVectorIntRef")
+}
+
+test.std.vector.int.const.ref <- function() {
+    fun <- stdVectorIntConstRef
+    x <- seq(1L, 5L, by=1L)
+    checkEquals(fun(x), 5, msg = "automatic conversion of stdVectorIntConstRef")
+}
+
+



More information about the Rcpp-commits mailing list