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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jun 14 13:05:50 CEST 2010


Author: romain
Date: 2010-06-14 13:05:49 +0200 (Mon, 14 Jun 2010)
New Revision: 1532

Added:
   pkg/Rcpp/inst/unitTests/runit.sugar.R
Log:
unit test for suga/any

Added: pkg/Rcpp/inst/unitTests/runit.sugar.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.sugar.R	                        (rev 0)
+++ pkg/Rcpp/inst/unitTests/runit.sugar.R	2010-06-14 11:05:49 UTC (rev 1532)
@@ -0,0 +1,37 @@
+#!/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/>.
+
+
+test.any <- function( ){
+
+	fx <- cxxfunction( signature( x = "numeric", y = "numeric" ), '
+	
+		NumericVector xx(x) ;
+		NumericVector yy(y) ;
+		
+		return any( xx < yy ) ;
+	
+	', plugin = "Rcpp" )
+	
+	checkTrue( ! fx( 1, 0 ) )
+	checkTrue( ! fx( 1:10, 2:11 ) )
+	checkTrue( fx( 0, 1 ) )
+	checkTrue( is.na( fx( NA, 1 ) ) )
+	
+}



More information about the Rcpp-commits mailing list