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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 26 12:08:02 CET 2012


Author: romain
Date: 2012-11-26 12:08:02 +0100 (Mon, 26 Nov 2012)
New Revision: 4043

Modified:
   pkg/Rcpp/inst/unitTests/cpp/reg_tests_0_10_1.cpp
   pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R
Log:
more

Modified: pkg/Rcpp/inst/unitTests/cpp/reg_tests_0_10_1.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/cpp/reg_tests_0_10_1.cpp	2012-11-26 10:02:42 UTC (rev 4042)
+++ pkg/Rcpp/inst/unitTests/cpp/reg_tests_0_10_1.cpp	2012-11-26 11:08:02 UTC (rev 4043)
@@ -8,6 +8,34 @@
 
 // [[Rcpp::export]]
 double RangeIndexer_sugar( NumericVector x ){
-    return max( x[ seq(0, 4) ], 5 ) ;    
+    return max( x[ seq(0, 4) ] ) ;    
 }
 
+// [[Rcpp::export]]
+IntegerVector test_self_match( CharacterVector x){
+    return self_match( x ) ;
+}
+
+// [[Rcpp::export]]
+IntegerVector test_table( CharacterVector x){
+    return table( x ) ;
+}
+
+// [[Rcpp::export]]
+LogicalVector test_duplicated( CharacterVector x){
+    return duplicated( x ) ;
+}
+
+// [[Rcpp::export]]
+IntegerVector test_union( IntegerVector x, IntegerVector y){
+    return union_( x, y) ;
+}
+// [[Rcpp::export]]
+IntegerVector test_setdiff( IntegerVector x, IntegerVector y){
+    return setdiff( x, y) ;
+}
+// [[Rcpp::export]]
+IntegerVector test_intersect( IntegerVector x, IntegerVector y){
+    return intersect( x, y ) ;
+}
+

Modified: pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R	2012-11-26 10:02:42 UTC (rev 4042)
+++ pkg/Rcpp/inst/unitTests/runit.reg_0_10_1.R	2012-11-26 11:08:02 UTC (rev 4043)
@@ -29,3 +29,37 @@
     x <- rnorm(10)
     checkEquals( RangeIndexer(x), max(x[1:5]) )    
 }
+
+test.self_match <- function(){
+    x <- sample( letters, 1000, replace = TRUE )
+    checkEquals( test_self_match(x), match(x,unique(x)) )    
+}
+
+test.table <- function(){
+    x <- sample( letters, 1000, replace = TRUE )
+    checkTrue( all( test_table(x) == table(x) ) )
+    checkTrue( all( names(test_table(x)) == names(table(x)) ) )
+}
+
+test.duplicated <- function(){
+    x <- sample( letters, 1000, replace = TRUE )
+    checkEquals( test_duplicated(x), duplicated(x) )
+}
+
+test.setdiff <- function(){
+    checkEquals( test_setdiff( 1:10, 1:5 ), setdiff( 1:10, 1:5 ) )
+}
+test.union <- function(){
+    checkEquals( test_union( 1:10, 1:5 ), union( 1:10, 1:5 ) )
+}
+test.intersect <- function(){
+    checkEquals( test_intersect( 1:10, 1:5 ), intersect( 1:10, 1:5 ) )
+}
+
+test.AreMacrosDefined <- function(){
+    checkTrue( Rcpp:::areMacrosDefined( "__cplusplus" ) )    
+}
+
+
+
+



More information about the Rcpp-commits mailing list