[Rcpp-commits] r4380 - in pkg/Rcpp: . inst/unitTests inst/unitTests/cpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 2 12:23:44 CEST 2013
Author: romain
Date: 2013-07-02 12:23:44 +0200 (Tue, 02 Jul 2013)
New Revision: 4380
Added:
pkg/Rcpp/inst/unitTests/cpp/wrap.cpp
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/unitTests/runit.Reference.R
pkg/Rcpp/inst/unitTests/runit.wrap.R
Log:
using sourceCpp in runit.wrap
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2013-07-02 09:11:35 UTC (rev 4379)
+++ pkg/Rcpp/ChangeLog 2013-07-02 10:23:44 UTC (rev 4380)
@@ -4,6 +4,7 @@
fill_dispatch) for the non trivial case, so it did not work
* unitTests/runit.Matrix.R: using sourceCpp
* unitTests/runit.misc.R: using sourceCpp
+ * unitTests/runit.wrap.R: using sourceCpp
* unitTests/runit.Vector.R: testing List( int, IntegerVector ) which
eventually uses fill__dispatch
* include/Rcpp/traits/r_type_traits.h: support for as<T&> and as<const T&>
Added: pkg/Rcpp/inst/unitTests/cpp/wrap.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/cpp/wrap.cpp (rev 0)
+++ pkg/Rcpp/inst/unitTests/cpp/wrap.cpp 2013-07-02 10:23:44 UTC (rev 4380)
@@ -0,0 +1,198 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// wrap.cpp: Rcpp R/C++ interface class library -- wrap unit tests
+//
+// Copyright (C) 2013 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/>.
+
+#include <Rcpp.h>
+using namespace Rcpp ;
+
+// [[Rcpp::export]]
+IntegerVector map_string_int(){
+ std::map< std::string, int > m ;
+ m["b"] = 100;
+ m["a"] = 200;
+ m["c"] = 300;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+NumericVector map_string_double(){
+ std::map<std::string,double> m ;
+ m["b"] = 100;
+ m["a"] = 200;
+ m["c"] = 300;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+LogicalVector map_string_bool(){
+ std::map<std::string,bool> m ;
+ m["b"] = true;
+ m["a"] = false;
+ m["c"] = true;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+RawVector map_string_Rbyte(){
+ std::map<std::string,Rbyte> m ;
+ m["b"] = (Rbyte)0;
+ m["a"] = (Rbyte)1;
+ m["c"] = (Rbyte)2;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+CharacterVector map_string_string(){
+ std::map<std::string,std::string> m ;
+ m["b"] = "foo" ;
+ m["a"] = "bar" ;
+ m["c"] = "bling" ;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+List map_string_generic(){
+ std::map< std::string,std::vector<int> > m ;
+ std::vector<int> b; b.push_back(1); b.push_back(2); m["b"] = b;
+ std::vector<int> a; a.push_back(1); a.push_back(2); a.push_back(2); m["a"] = a;
+ std::vector<int> c; c.push_back(1); c.push_back(2); c.push_back(2); c.push_back(2); m["c"] = c;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+IntegerVector multimap_string_int(){
+ std::multimap< std::string, int > m;
+ m.insert( std::pair<std::string,int>("b", 100));
+ m.insert( std::pair<std::string,int>("a", 200));
+ m.insert( std::pair<std::string,int>("c", 300));
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+NumericVector multimap_string_double(){
+ std::multimap<std::string,double> m ;
+ m.insert( std::pair<std::string,double>("b", 100) );
+ m.insert( std::pair<std::string,double>("a", 200) );
+ m.insert( std::pair<std::string,double>("c", 300) );
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+LogicalVector multimap_string_bool(){
+ std::multimap<std::string,bool> m ;
+ m.insert( std::pair<std::string,bool>("b", true ) ) ;
+ m.insert( std::pair<std::string,bool>("a", false) ) ;
+ m.insert( std::pair<std::string,bool>("c", true ) ) ;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+RawVector multimap_string_Rbyte(){
+ std::multimap<std::string,Rbyte> m ;
+ m.insert( std::pair<std::string,Rbyte>("b", (Rbyte)0) );
+ m.insert( std::pair<std::string,Rbyte>("a", (Rbyte)1) );
+ m.insert( std::pair<std::string,Rbyte>("c", (Rbyte)2) );
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+CharacterVector multimap_string_string(){
+ std::multimap<std::string,std::string> m ;
+ m.insert( std::pair<std::string,std::string>( "b", "foo" ) ) ;
+ m.insert( std::pair<std::string,std::string>( "a", "bar" ) ) ;
+ m.insert( std::pair<std::string,std::string>( "c", "bling") ) ;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+List multimap_string_generic(){
+ typedef std::pair<std::string,std::vector<int> > _pair ;
+ std::multimap< std::string,std::vector<int> > m ;
+ std::vector<int> b ; b.push_back(1) ; b.push_back(2) ;
+ m.insert( _pair("b", b) );
+
+ std::vector<int> a ; a.push_back(1) ; a.push_back(2) ; a.push_back(2) ;
+ m.insert( _pair("a", a) );
+
+ std::vector<int> c ; c.push_back(1) ; c.push_back(2) ; c.push_back(2) ; c.push_back(2) ;
+ m.insert( _pair("c", c) );
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+SEXP null_const_char(){ const char *p = NULL; return wrap(p); }
+
+// [[Rcpp::export]]
+SEXP nonnull_const_char(){ const char *p = "foo"; return wrap(p) ; }
+
+// [[Rcpp::export]]
+IntegerVector unordered_map_string_int(){
+ RCPP_UNORDERED_MAP< std::string, int > m ;
+ m["b"] = 100;
+ m["a"] = 200;
+ m["c"] = 300;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+NumericVector unordered_map_string_double(){
+ RCPP_UNORDERED_MAP<std::string,double> m ;
+ m["b"] = 100;
+ m["a"] = 200;
+ m["c"] = 300;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+LogicalVector unordered_map_string_bool(){
+ RCPP_UNORDERED_MAP<std::string,bool> m ;
+ m["b"] = true;
+ m["a"] = false;
+ m["c"] = true;
+ return wrap(m) ;
+}
+
+// [[Rcpp::export]]
+RawVector unordered_map_string_Rbyte(){
+ RCPP_UNORDERED_MAP<std::string,Rbyte> m ;
+ m["b"] = (Rbyte)0;
+ m["a"] = (Rbyte)1;
+ m["c"] = (Rbyte)2;
+ return wrap(m);
+}
+
+// [[Rcpp::export]]
+CharacterVector unordered_map_string_string(){
+ RCPP_UNORDERED_MAP<std::string,std::string> m ;
+ m["b"] = "foo" ;
+ m["a"] = "bar" ;
+ m["c"] = "bling" ;
+ return wrap(m) ;
+}
+
+// [[Rcpp::export]]
+List unordered_map_string_generic(){
+ RCPP_UNORDERED_MAP< std::string,std::vector<int> > m ;
+ std::vector<int> b; b.push_back(1); b.push_back(2); m["b"] = b ;
+ std::vector<int> a; a.push_back(1); a.push_back(2); a.push_back(2); m["a"] = a;
+ std::vector<int> c; c.push_back(1); c.push_back(2); c.push_back(2); c.push_back(2); m["c"] = c;
+ return wrap(m);
+}
+
Modified: pkg/Rcpp/inst/unitTests/runit.Reference.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Reference.R 2013-07-02 09:11:35 UTC (rev 4379)
+++ pkg/Rcpp/inst/unitTests/runit.Reference.R 2013-07-02 10:23:44 UTC (rev 4380)
@@ -21,12 +21,10 @@
if (.runThisTest) {
-.setUp <- function() {
- sourceCpp(file.path(pathRcppTests, "cpp/Reference.cpp"))
-}
+.setUp <- Rcpp:::unit_test_setup( "Reference.cpp" )
test.Reference <- function(){
- Instrument <-setRefClass(
+ Instrument <- setRefClass(
Class="Instrument",
fields=list("id"="character", "description"="character")
)
@@ -37,5 +35,4 @@
checkEquals( runit_Reference_getId(instrument), "AAPL", msg = ".field" )
}
-
}
Modified: pkg/Rcpp/inst/unitTests/runit.wrap.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.wrap.R 2013-07-02 09:11:35 UTC (rev 4379)
+++ pkg/Rcpp/inst/unitTests/runit.wrap.R 2013-07-02 10:23:44 UTC (rev 4380)
@@ -21,342 +21,133 @@
if (.runThisTest) {
-definitions <- function(){
+.setUp <- Rcpp:::unit_test_setup( "wrap.cpp" )
- f <- list("map_string_int"=list(
- signature(),
- 'std::map< std::string, int > m ;
- m["b"] = 100;
- m["a"] = 200;
- m["c"] = 300;
- return wrap(m);')
-
- ,"map_string_double"=list(
- signature(),
- 'std::map<std::string,double> m ;
- m["b"] = 100;
- m["a"] = 200;
- m["c"] = 300;
- return wrap(m);')
-
-
- ,"map_string_bool"=list(
- signature(),
- 'std::map<std::string,bool> m ;
- m["b"] = true;
- m["a"] = false;
- m["c"] = true;
- return wrap(m);')
-
- ,"map_string_Rbyte"=list(
- signature(),
- 'std::map<std::string,Rbyte> m ;
- m["b"] = (Rbyte)0;
- m["a"] = (Rbyte)1;
- m["c"] = (Rbyte)2;
- return wrap(m);')
-
- ,"map_string_string"=list(
- signature(),
- 'std::map<std::string,std::string> m ;
- m["b"] = "foo" ;
- m["a"] = "bar" ;
- m["c"] = "bling" ;
- return wrap(m);')
-
- ,"map_string_generic"=list(
- signature(),
- 'std::map< std::string,std::vector<int> > m ;
- std::vector<int> b; b.push_back(1); b.push_back(2); m["b"] = b;
- std::vector<int> a; a.push_back(1); a.push_back(2); a.push_back(2); m["a"] = a;
- std::vector<int> c; c.push_back(1); c.push_back(2); c.push_back(2); c.push_back(2); m["c"] = c;
- return wrap(m);')
-
- ,"multimap_string_int"=list(
- signature(),
- 'std::multimap< std::string, int > m;
- m.insert( std::pair<std::string,int>("b", 100));
- m.insert( std::pair<std::string,int>("a", 200));
- m.insert( std::pair<std::string,int>("c", 300));
- return wrap(m);')
-
- ,"multimap_string_double"=list(
- signature(),
- 'std::multimap<std::string,double> m ;
- m.insert( std::pair<std::string,double>("b", 100) );
- m.insert( std::pair<std::string,double>("a", 200) );
- m.insert( std::pair<std::string,double>("c", 300) );
- return wrap(m);')
-
- ,"multimap_string_bool"=list(
- signature(),
- 'std::multimap<std::string,bool> m ;
- m.insert( std::pair<std::string,bool>("b", true ) ) ;
- m.insert( std::pair<std::string,bool>("a", false) ) ;
- m.insert( std::pair<std::string,bool>("c", true ) ) ;
- return wrap(m);')
-
- ,"multimap_string_Rbyte"=list(
- signature(),
- 'std::multimap<std::string,Rbyte> m ;
- m.insert( std::pair<std::string,Rbyte>("b", (Rbyte)0) );
- m.insert( std::pair<std::string,Rbyte>("a", (Rbyte)1) );
- m.insert( std::pair<std::string,Rbyte>("c", (Rbyte)2) );
- return wrap(m);')
-
- ,"multimap_string_string"=list(
- signature(),
- 'std::multimap<std::string,std::string> m ;
- m.insert( std::pair<std::string,std::string>( "b", "foo" ) ) ;
- m.insert( std::pair<std::string,std::string>( "a", "bar" ) ) ;
- m.insert( std::pair<std::string,std::string>( "c", "bling") ) ;
- return wrap(m);')
-
- ,"multimap_string_generic"=list(
- signature(),
- 'typedef std::pair<std::string,std::vector<int> > _pair ;
- std::multimap< std::string,std::vector<int> > m ;
- std::vector<int> b ; b.push_back(1) ; b.push_back(2) ;
- m.insert( _pair("b", b) );
-
- std::vector<int> a ; a.push_back(1) ; a.push_back(2) ; a.push_back(2) ;
- m.insert( _pair("a", a) );
-
- std::vector<int> c ; c.push_back(1) ; c.push_back(2) ; c.push_back(2) ; c.push_back(2) ;
- m.insert( _pair("c", c) );
- return wrap(m);')
-
- ,"null_const_char"=list(
- signature(),
- 'const char *p = NULL;
- return wrap(p);')
-
- ,"nonnull_const_char"=list(
- signature(),
- 'const char *p = "foo";
- return wrap(p);')
-
- )
-
-
- ## definition of all the tr1 functions at once, appended to existing list
- g <- list("unordered_map_string_int"=list(
- signature(),
- 'RCPP_UNORDERED_MAP< std::string, int > m ;
- m["b"] = 100;
- m["a"] = 200;
- m["c"] = 300;
- return wrap(m);')
-
- ,"unordered_map_string_double"=list(
- signature(),
- 'RCPP_UNORDERED_MAP<std::string,double> m ;
- m["b"] = 100;
- m["a"] = 200;
- m["c"] = 300;
- return wrap(m);')
-
- ,"unordered_map_string_bool"=list(
- signature(),
- 'RCPP_UNORDERED_MAP<std::string,bool> m ;
- m["b"] = true;
- m["a"] = false;
- m["c"] = true;
- return wrap(m) ;
- ')
-
- ,"unordered_map_string_Rbyte"=list(
- signature(),
- 'RCPP_UNORDERED_MAP<std::string,Rbyte> m ;
- m["b"] = (Rbyte)0;
- m["a"] = (Rbyte)1;
- m["c"] = (Rbyte)2;
- return wrap(m);')
-
- ,"unordered_map_string_string"=list(
- signature(),
- 'RCPP_UNORDERED_MAP<std::string,std::string> m ;
- m["b"] = "foo" ;
- m["a"] = "bar" ;
- m["c"] = "bling" ;
- return wrap(m) ;
- ')
-
- ,"unordered_map_string_generic"=list(
- signature(),
- 'RCPP_UNORDERED_MAP< std::string,std::vector<int> > m ;
- std::vector<int> b; b.push_back(1); b.push_back(2); m["b"] = b ;
- std::vector<int> a; a.push_back(1); a.push_back(2); a.push_back(2); m["a"] = a;
- std::vector<int> c; c.push_back(1); c.push_back(2); c.push_back(2); c.push_back(2); m["c"] = c;
- return wrap(m);')
-
- )
-
- if (Rcpp:::capabilities()[["tr1 unordered maps"]]) {
- f <- c(f,g)
- }
- f
-}
-
-.setUp <- function() {
- if( ! exists( ".rcpp.wrap", globalenv() )) {
- fun <- Rcpp:::compile_unit_tests( definitions() )
- assign( ".rcpp.wrap", fun, globalenv() )
- }
-}
-
-
test.wrap.map.string.int <- function(){
- fun <- .rcpp.wrap$map_string_int
- checkEquals(fun(),
+ checkEquals(map_string_int(),
c( a = 200L, b = 100L, c = 300L),
msg = "wrap( map<string,int>) " )
}
test.wrap.map.string.double <- function(){
- fun <- .rcpp.wrap$map_string_double
- checkEquals(fun(),
+ checkEquals(map_string_double(),
c( a = 200, b = 100, c = 300),
msg = "wrap( map<string,double>) " )
}
test.wrap.map.string.bool <- function(){
- fun <- .rcpp.wrap$map_string_bool
- checkEquals(fun(),
+ checkEquals(map_string_bool(),
c( a = FALSE, b = TRUE, c = TRUE ),
msg = "wrap( map<string,bool>) " )
}
test.wrap.map.string.Rbyte <- function(){
- fun <- .rcpp.wrap$map_string_Rbyte
- checkEquals(fun(),
+ checkEquals(map_string_Rbyte(),
c( a = as.raw(1), b = as.raw(0), c = as.raw(2) ),
msg = "wrap( map<string,Rbyte>) " )
}
test.wrap.map.string.string <- function(){
- fun <- .rcpp.wrap$map_string_string
- checkEquals(fun(),
+ checkEquals(map_string_string(),
c( a = "bar", b = "foo", c = "bling" ),
msg = "wrap( map<string,string>) " )
}
test.wrap.map.string.generic <- function(){
- fun <- .rcpp.wrap$map_string_generic
- checkEquals(fun(),
+ checkEquals(map_string_generic(),
list( a = c(1L, 2L, 2L), b = c(1L, 2L), c = c(1L,2L,2L,2L) ) ,
msg = "wrap( map<string,vector<int>>) " )
}
test.wrap.multimap.string.int <- function(){
- fun <- .rcpp.wrap$multimap_string_int
- checkEquals(fun(),
+ checkEquals(multimap_string_int(),
c( a = 200L, b = 100L, c = 300L),
msg = "wrap( multimap<string,int>) ")
}
test.wrap.multimap.string.double <- function(){
- fun <- .rcpp.wrap$multimap_string_double
- checkEquals(fun(),
+ checkEquals(multimap_string_double(),
c( a = 200, b = 100, c = 300),
msg = "wrap( multimap<string,double>) " )
}
test.wrap.multimap.string.bool <- function(){
- fun <- .rcpp.wrap$multimap_string_bool
- checkEquals(fun(),
+ checkEquals(multimap_string_bool(),
c( a = FALSE, b = TRUE, c = TRUE ),
msg = "wrap( multimap<string,bool>)")
}
test.wrap.multimap.string.Rbyte <- function(){
- fun <- .rcpp.wrap$multimap_string_Rbyte
- checkEquals(fun(),
+ checkEquals(multimap_string_Rbyte(),
c( a = as.raw(1), b = as.raw(0), c = as.raw(2) ),
msg = "wrap( multimap<string,Rbyte>) " )
}
test.wrap.multimap.string.string <- function(){
- fun <- .rcpp.wrap$multimap_string_string
- checkEquals(fun(),
+ checkEquals(multimap_string_string(),
c( a = "bar", b = "foo", c = "bling" ),
msg = "wrap( multimap<string,string>) " )
}
test.wrap.multimap.string.generic <- function(){
- fun <- .rcpp.wrap$multimap_string_generic
- checkEquals(fun(),
+ checkEquals(multimap_string_generic(),
list( a = c(1L, 2L, 2L), b = c(1L, 2L), c = c(1L,2L,2L,2L) ) ,
msg = "wrap( multimap<string,vector<int>>) " )
}
test.null.const.char <- function() {
- fun <- .rcpp.wrap$null_const_char
- checkEquals(fun(),
+ checkEquals(null_const_char(),
NULL,
msg = "null const char*")
}
test.nonnull.const.char <- function() {
- fun <- .rcpp.wrap$nonnull_const_char
- checkEquals(fun(),
+ checkEquals(nonnull_const_char(),
"foo",
msg = "null const char*")
}
-## tr1::unordered_map
-if (Rcpp:::capabilities()[["tr1 unordered maps"]]) {
+test.wrap.unordered.map.string.int <- function(){
+ res <- unordered_map_string_int()
+ checkEquals( res[["a"]], 200L, msg = "wrap( tr1::unordered_map<string,int>) " )
+ checkEquals( res[["b"]], 100L, msg = "wrap( tr1::unordered_map<string,int>) " )
+ checkEquals( res[["c"]], 300L, msg = "wrap( tr1::unordered_map<string,int>) " )
+}
- test.wrap.unordered.map.string.int <- function(){
- fun <- .rcpp.wrap$unordered_map_string_int
- res <- fun()
- checkEquals( res[["a"]], 200L, msg = "wrap( tr1::unordered_map<string,int>) " )
- checkEquals( res[["b"]], 100L, msg = "wrap( tr1::unordered_map<string,int>) " )
- checkEquals( res[["c"]], 300L, msg = "wrap( tr1::unordered_map<string,int>) " )
- }
+test.wrap.unordered.map.string.double <- function(){
+ res <- unordered_map_string_double()
+ checkEquals( res[["a"]], 200, msg = "wrap( tr1::unordered_map<string,double>) " )
+ checkEquals( res[["b"]], 100, msg = "wrap( tr1::unordered_map<string,double>) " )
+ checkEquals( res[["c"]], 300, msg = "wrap( tr1::unordered_map<string,double>) " )
+}
- test.wrap.unordered.map.string.double <- function(){
- fun <- .rcpp.wrap$unordered_map_string_double
- res <- fun()
- checkEquals( res[["a"]], 200, msg = "wrap( tr1::unordered_map<string,double>) " )
- checkEquals( res[["b"]], 100, msg = "wrap( tr1::unordered_map<string,double>) " )
- checkEquals( res[["c"]], 300, msg = "wrap( tr1::unordered_map<string,double>) " )
- }
+test.wrap.unordered.map.string.bool <- function(){
+ res <- unordered_map_string_bool()
+ checkEquals( res[["a"]], FALSE, msg = "wrap( tr1::unordered_map<string,bool>) " )
+ checkEquals( res[["b"]], TRUE , msg = "wrap( tr1::unordered_map<string,bool>) " )
+ checkEquals( res[["c"]], TRUE , msg = "wrap( tr1::unordered_map<string,bool>) " )
+}
- test.wrap.unordered.map.string.bool <- function(){
- fun <- .rcpp.wrap$unordered_map_string_bool
- res <- fun()
- checkEquals( res[["a"]], FALSE, msg = "wrap( tr1::unordered_map<string,bool>) " )
- checkEquals( res[["b"]], TRUE , msg = "wrap( tr1::unordered_map<string,bool>) " )
- checkEquals( res[["c"]], TRUE , msg = "wrap( tr1::unordered_map<string,bool>) " )
- }
+test.wrap.unordered.map.string.Rbyte <- function(){
+ res <- unordered_map_string_Rbyte()
+ checkEquals( res[["a"]], as.raw(1), msg = "wrap( tr1::unordered_map<string,Rbyte>) " )
+ checkEquals( res[["b"]], as.raw(0), msg = "wrap( tr1::unordered_map<string,Rbyte>) " )
+ checkEquals( res[["c"]], as.raw(2), msg = "wrap( tr1::unordered_map<string,Rbyte>) " )
+}
- test.wrap.unordered.map.string.Rbyte <- function(){
- fun <- .rcpp.wrap$unordered_map_string_Rbyte
- res <- fun()
- checkEquals( res[["a"]], as.raw(1), msg = "wrap( tr1::unordered_map<string,Rbyte>) " )
- checkEquals( res[["b"]], as.raw(0), msg = "wrap( tr1::unordered_map<string,Rbyte>) " )
- checkEquals( res[["c"]], as.raw(2), msg = "wrap( tr1::unordered_map<string,Rbyte>) " )
- }
+test.wrap.unordered.map.string.string <- function(){
+ res <- unordered_map_string_string()
+ checkEquals( res[["a"]], "bar" , msg = "wrap( tr1::unordered_map<string,string>) " )
+ checkEquals( res[["b"]], "foo" , msg = "wrap( tr1::unordered_map<string,string>) " )
+ checkEquals( res[["c"]], "bling" , msg = "wrap( tr1::unordered_map<string,string>) " )
+}
- test.wrap.unordered.map.string.string <- function(){
- fun <- .rcpp.wrap$unordered_map_string_string
- res <- fun()
- checkEquals( res[["a"]], "bar" , msg = "wrap( tr1::unordered_map<string,string>) " )
- checkEquals( res[["b"]], "foo" , msg = "wrap( tr1::unordered_map<string,string>) " )
- checkEquals( res[["c"]], "bling" , msg = "wrap( tr1::unordered_map<string,string>) " )
- }
+test.wrap.unordered.map.string.generic <- function(){
+ res <- unordered_map_string_generic()
+ checkEquals( res[["a"]], c(1L,2L,2L) , msg = "wrap( tr1::unordered_map<string,vector<int>>) " )
+ checkEquals( res[["b"]], c(1L,2L) , msg = "wrap( tr1::unordered_map<string,vector<int>>) " )
+ checkEquals( res[["c"]], c(1L,2L,2L,2L) , msg = "wrap( tr1::unordered_map<string,vector<int>>) " )
+}
- test.wrap.unordered.map.string.generic <- function(){
- fun <- .rcpp.wrap$unordered_map_string_generic
- res <- fun()
- checkEquals( res[["a"]], c(1L,2L,2L) , msg = "wrap( tr1::unordered_map<string,vector<int>>) " )
- checkEquals( res[["b"]], c(1L,2L) , msg = "wrap( tr1::unordered_map<string,vector<int>>) " )
- checkEquals( res[["c"]], c(1L,2L,2L,2L) , msg = "wrap( tr1::unordered_map<string,vector<int>>) " )
- }
-
-} # if( Rcpp:::capabilities("tr1 unordered maps") )
-
-
}
More information about the Rcpp-commits
mailing list