1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
## Copyright (C) 2010 - 2019 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/>.
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
Rcpp::sourceCpp("cpp/wrap.cpp")
# test.wrap.map.string.int <- function(){
expect_equal(map_string_int(), c( a = 200L, b = 100L, c = 300L), info = "wrap( map<string,int>) " )
# test.wrap.map.string.double <- function(){
expect_equal(map_string_double(), c( a = 200, b = 100, c = 300), info = "wrap( map<string,double>) " )
# test.wrap.map.string.bool <- function(){
expect_equal(map_string_bool(), c( a = FALSE, b = TRUE, c = TRUE ), info = "wrap( map<string,bool>) " )
# test.wrap.map.string.Rbyte <- function(){
expect_equal(map_string_Rbyte(), c( a = as.raw(1), b = as.raw(0), c = as.raw(2) ),
info = "wrap( map<string,Rbyte>) " )
# test.wrap.map.string.string <- function(){
expect_equal(map_string_string(), c( a = "bar", b = "foo", c = "bling" ), info = "wrap( map<string,string>) " )
# test.wrap.map.string.generic <- function(){
expect_equal(map_string_generic(), list( a = c(1L, 2L, 2L), b = c(1L, 2L), c = c(1L,2L,2L,2L) ) ,
info = "wrap( map<string,vector<int>>) " )
# test.wrap.multimap.string.int <- function(){
expect_equal(multimap_string_int(), c( a = 200L, b = 100L, c = 300L),
info = "wrap( multimap<string,int>) ")
# test.wrap.multimap.string.double <- function(){
expect_equal(multimap_string_double(), c( a = 200, b = 100, c = 300),
info = "wrap( multimap<string,double>) " )
# test.wrap.multimap.string.bool <- function(){
expect_equal(multimap_string_bool(), c( a = FALSE, b = TRUE, c = TRUE ),
info = "wrap( multimap<string,bool>)")
# test.wrap.multimap.string.Rbyte <- function(){
expect_equal(multimap_string_Rbyte(), c( a = as.raw(1), b = as.raw(0), c = as.raw(2) ),
info = "wrap( multimap<string,Rbyte>) " )
# test.wrap.multimap.string.string <- function(){
expect_equal(multimap_string_string(), c( a = "bar", b = "foo", c = "bling" ),
info = "wrap( multimap<string,string>) " )
# test.wrap.multimap.string.generic <- function(){
expect_equal(multimap_string_generic(), list( a = c(1L, 2L, 2L), b = c(1L, 2L), c = c(1L,2L,2L,2L) ) ,
info = "wrap( multimap<string,vector<int>>) " )
# test.nonnull.const.char <- function() {
expect_equal(nonnull_const_char(), "foo", info = "null const char*")
# test.wrap.unordered.map.string.int <- function(){
res <- unordered_map_string_int()
expect_equal( res[["a"]], 200L, info = "wrap( tr1::unordered_map<string,int>) " )
expect_equal( res[["b"]], 100L, info = "wrap( tr1::unordered_map<string,int>) " )
expect_equal( res[["c"]], 300L, info = "wrap( tr1::unordered_map<string,int>) " )
# test.wrap.unordered.map.rcpp.string.int <- function(){
res <- unordered_map_rcpp_string_int(c("a", "b", "c"))
expect_equal( res[["a"]], 200L, info = "wrap( tr1::unordered_map<Rcpp::String,int>) " )
expect_equal( res[["b"]], 100L, info = "wrap( tr1::unordered_map<Rcpp::String,int>) " )
expect_equal( res[["c"]], 300L, info = "wrap( tr1::unordered_map<Rcpp::String,int>) " )
# test.unordered.set.rcpp.string <- function(){
expect_equal(unordered_set_rcpp_string(c("a", "b", "c", "b")),
c(FALSE, FALSE, FALSE, TRUE), info = "wrap( tr1::unordered_set<Rcpp::String>) " )
# test.wrap.unordered.map.string.double <- function(){
res <- unordered_map_string_double()
expect_equal( res[["a"]], 200, info = "wrap( tr1::unordered_map<string,double>) " )
expect_equal( res[["b"]], 100, info = "wrap( tr1::unordered_map<string,double>) " )
expect_equal( res[["c"]], 300, info = "wrap( tr1::unordered_map<string,double>) " )
# test.wrap.unordered.map.string.bool <- function(){
res <- unordered_map_string_bool()
expect_equal( res[["a"]], FALSE, info = "wrap( tr1::unordered_map<string,bool>) " )
expect_equal( res[["b"]], TRUE , info = "wrap( tr1::unordered_map<string,bool>) " )
expect_equal( res[["c"]], TRUE , info = "wrap( tr1::unordered_map<string,bool>) " )
# test.wrap.unordered.map.string.Rbyte <- function(){
res <- unordered_map_string_Rbyte()
expect_equal( res[["a"]], as.raw(1), info = "wrap( tr1::unordered_map<string,Rbyte>) " )
expect_equal( res[["b"]], as.raw(0), info = "wrap( tr1::unordered_map<string,Rbyte>) " )
expect_equal( res[["c"]], as.raw(2), info = "wrap( tr1::unordered_map<string,Rbyte>) " )
# test.wrap.unordered.map.string.string <- function(){
res <- unordered_map_string_string()
expect_equal( res[["a"]], "bar" , info = "wrap( tr1::unordered_map<string,string>) " )
expect_equal( res[["b"]], "foo" , info = "wrap( tr1::unordered_map<string,string>) " )
expect_equal( res[["c"]], "bling" , info = "wrap( tr1::unordered_map<string,string>) " )
# test.wrap.unordered.map.string.generic <- function(){
res <- unordered_map_string_generic()
expect_equal( res[["a"]], c(1L,2L,2L) , info = "wrap( tr1::unordered_map<string,vector<int>>) " )
expect_equal( res[["b"]], c(1L,2L) , info = "wrap( tr1::unordered_map<string,vector<int>>) " )
expect_equal( res[["c"]], c(1L,2L,2L,2L) , info = "wrap( tr1::unordered_map<string,vector<int>>) " )
# test.wrap.map.int.double <- function(){
expect_equal(map_int_double(), c("-1" = 3, "0" = 2 ), info = "std::map<int,double>")
# test.wrap.map.double.double <- function(){
expect_equal(map_double_double(), c("0" = 2, "1.2" = 3 ), info = "std::map<double,double>")
# test.wrap.map.int.vector_double <- function(){
expect_equal(map_int_vector_double(), list("0" = c(1,2), "1" = c(2,3) ), info = "std::map<double, std::vector<double> >")
# test.wrap.map.int.Foo <- function(){
expect_equal(sapply( map_int_Foo(), function(.) .$get() ),
c("0" = 2, "1" = 3 ), info = "std::map<int, MODULE EXPOSED CLASS >")
# test.wrap.vector.Foo <- function(){
expect_equal(sapply( vector_Foo(), function(.) .$get() ), c(2, 3),
info = "std::vector< MODULE EXPOSED CLASS >")
# test.wrap.custom.class <- function() {
expect_equal(test_wrap_custom_class(), 42)
# test.wrap.string_view <- function() {
expect_equal(test_wrap_string_view(), "test string value")
|