Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
complete test cases for setting NamesProxy
  • Loading branch information
Enchufa2 authored and eddelbuettel committed Apr 7, 2026
commit 0c95245ef9d6e4f3f6fd0fc7ee9c3e641a795a52
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

* inst/include/Rcpp/Function.h: Further refinement for 4.6.0 to not
require R_NamespaceRegistry, using R_getRegisteredNamespace() instead
2026-04-06 Iñaki Ucar <iucar@fedoraproject.org>

* inst/tinytest/test_vector.R: Complete test cases for setting NamesProxy
* inst/tinytest/cpp/Vector.cpp: Idem

2026-04-03 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/proxy/NamesProxy.h (set): Only set non-null values
Expand Down
6 changes: 1 addition & 5 deletions inst/tinytest/cpp/Vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ IntegerVector integer_range_ctor_2(){
}

// [[Rcpp::export]]
IntegerVector integer_names_set(){
IntegerVector y(2) ;
std::vector<std::string> names(2) ;
names[0] = "foo" ;
names[1] = "bar" ;
IntegerVector integer_names_set(IntegerVector y, SEXP names) {
y.names() = names ;
return y ;
}
Expand Down
5 changes: 4 additions & 1 deletion inst/tinytest/test_vector.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ expect_equal( fun(), 0:3, info = "assign(int*, int*)" )

# test.IntegerVector.names.set <- function(){
fun <- integer_names_set
expect_equal(names(fun()), c("foo", "bar"), info = "Vector::names" )
x <- 1:2
expect_equal(names(fun(x, c("foo", "bar"))), c("foo", "bar"), info = "Vector::names set" )
expect_equal(names(fun(x, "foo")), c("foo", NA), info = "Vector::names set shorter" )
expect_equal(names(fun(x, NULL)), NULL, info = "Vector::names unset" )

# test.IntegerVector.names.get <- function(){
fun <- integer_names_get
Expand Down
Loading