[Rcpp-commits] r1688 - in pkg/Rcpp: inst/unitTests src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 23 21:00:45 CEST 2010


Author: romain
Date: 2010-06-23 21:00:44 +0200 (Wed, 23 Jun 2010)
New Revision: 1688

Modified:
   pkg/Rcpp/inst/unitTests/runit.Date.R
   pkg/Rcpp/src/DateVector.cpp
Log:
DateVector unit test

Modified: pkg/Rcpp/inst/unitTests/runit.Date.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Date.R	2010-06-23 18:57:48 UTC (rev 1687)
+++ pkg/Rcpp/inst/unitTests/runit.Date.R	2010-06-23 19:00:44 UTC (rev 1688)
@@ -51,3 +51,13 @@
     checkEquals(fx(), rep(as.Date("2005-12-31"),2), msg = "Date.vector")
 }
 
+test.vector.DateVector <- function(){
+	fx <- cxxfunction( , '
+		DateVector v(2) ;
+		v[0] = Date(2005,12,31) ;
+		v[1] = Date(12,31,2005) ;
+		return wrap( v ) ;
+	', plugin = "Rcpp" )
+    checkEquals(fx(), rep(as.Date("2005-12-31"),2), msg = "Date.vector")
+}
+

Modified: pkg/Rcpp/src/DateVector.cpp
===================================================================
--- pkg/Rcpp/src/DateVector.cpp	2010-06-23 18:57:48 UTC (rev 1687)
+++ pkg/Rcpp/src/DateVector.cpp	2010-06-23 19:00:44 UTC (rev 1688)
@@ -40,7 +40,7 @@
 
 	DateVector::DateVector(int n) : v(n){}
 
-	const Date & DateVector::operator()(unsigned int i) const {
+	const Date & DateVector::operator()(unsigned int i) const throw(std::range_error) {
 		if (i >= v.size()) {
 			std::ostringstream oss;
 			oss << "DateVector: subscript out of range: " << i;
@@ -49,7 +49,7 @@
 		return v[i];
 	}
 
-	Date & DateVector::operator()(unsigned int i) {
+	Date & DateVector::operator()(unsigned int i) throw(std::range_error) {
 		if (i >= v.size()) {
 			std::ostringstream oss;
 			oss << "DateVector: subscript out of range: " << i;



More information about the Rcpp-commits mailing list