Skip to content

Commit 0ed6d80

Browse files
➕ test for lists accross storage policies
1 parent 894d6e4 commit 0ed6d80

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

inst/unitTests/cpp/Vector.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,3 +855,16 @@ int CharacterVectorNoProtect(Vector<STRSXP, NoProtectStorage> s){
855855
return s.size();
856856
}
857857

858+
// [[Rcpp::export]]
859+
CharacterVector CharacterVectorNoProtect_crosspolicy(Vector<STRSXP, NoProtectStorage> s){
860+
CharacterVector s2(1) ;
861+
s2[0] = s[0];
862+
return s;
863+
}
864+
865+
// [[Rcpp::export]]
866+
List ListNoProtect_crosspolicy(Vector<VECSXP, NoProtectStorage> data){
867+
List data2(1) ;
868+
data2[0] = data[0];
869+
return data2;
870+
}

inst/unitTests/runit.Vector.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,5 +761,15 @@ if (.runThisTest) {
761761
checkEquals(CharacterVectorNoProtect(s), 1L)
762762
checkEquals(s, "")
763763
}
764-
}
765764

765+
test.CharacterVectorNoProtect_crosspolicy <- function(){
766+
s <- "foo"
767+
checkEquals(CharacterVectorNoProtect_crosspolicy(s), s)
768+
}
769+
770+
test.ListNoProtect_crosspolicy <- function(){
771+
data <- list(1:10)
772+
data2 <- ListNoProtect_crosspolicy(data)
773+
checkEquals(data, data2)
774+
}
775+
}

0 commit comments

Comments
 (0)