[Rcpp-commits] r496 - pkg/inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 28 04:43:17 CET 2010


Author: edd
Date: 2010-01-28 04:43:16 +0100 (Thu, 28 Jan 2010)
New Revision: 496

Added:
   pkg/inst/unitTests/runit.RcppVector.R
   pkg/inst/unitTests/runit.RcppVectorView.R
Log:
two more unit test files


Added: pkg/inst/unitTests/runit.RcppVector.R
===================================================================
--- pkg/inst/unitTests/runit.RcppVector.R	                        (rev 0)
+++ pkg/inst/unitTests/runit.RcppVector.R	2010-01-28 03:43:16 UTC (rev 496)
@@ -0,0 +1,57 @@
+#!/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/>.
+
+.setUp <- function(){
+    suppressMessages( require( inline ) )
+}
+
+test.RcppVector.int <- function() {
+    src <- 'RcppVector<int> m(x);
+            RcppResultSet rs;
+            rs.add("size",  m.size());
+            rs.add("p2",    m(1));
+	    return rs.getReturnList();';
+    funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
+    checkEquals(funx(x=c(1:6)), list(size=6, p2=2), msg="RcppVector.int")
+}
+
+test.RcppVector.double <- function() {
+    src <- 'RcppVector<double> m(x);
+            RcppResultSet rs;
+            rs.add("size", m.size());
+            rs.add("p2",   m(1));
+	    return rs.getReturnList();';
+    funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
+    checkEquals(funx(x=c(1:6)), list(size=6, p2=2), msg="RcppVector.double")
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: pkg/inst/unitTests/runit.RcppVectorView.R
===================================================================
--- pkg/inst/unitTests/runit.RcppVectorView.R	                        (rev 0)
+++ pkg/inst/unitTests/runit.RcppVectorView.R	2010-01-28 03:43:16 UTC (rev 496)
@@ -0,0 +1,57 @@
+#!/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/>.
+
+.setUp <- function(){
+    suppressMessages( require( inline ) )
+}
+
+test.RcppVectorView.int <- function() {
+    src <- 'RcppVectorView<int> m(x);
+            RcppResultSet rs;
+            rs.add("size",  m.size());
+            rs.add("p2",    m(1));
+	    return rs.getReturnList();';
+    funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
+    checkEquals(funx(x=c(1:6)), list(size=6, p2=2), msg="RcppVectorView.int")
+}
+
+test.RcppVectorView.double <- function() {
+    src <- 'RcppVectorView<double> m(x);
+            RcppResultSet rs;
+            rs.add("size", m.size());
+            rs.add("p2",   m(1));
+	    return rs.getReturnList();';
+    funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
+    checkEquals(funx(x=1.0*c(1:6)), list(size=6, p2=2), msg="RcppVectorView.double")
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+



More information about the Rcpp-commits mailing list