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
Next Next commit
Conditrion nullable<String> test on R 4.3.0 or later
  • Loading branch information
eddelbuettel committed Apr 9, 2026
commit 4422a79f6a6dcf429edaeb25fd77b18fb64a387d
2 changes: 2 additions & 0 deletions inst/tinytest/cpp/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,15 @@ SEXP testNullableIsUsable(const Nullable<NumericMatrix>& M) {
}
}

#if R_VERSION > R_Version(4,3,0)
// [[Rcpp::export]]
String testNullableString(Rcpp::Nullable<Rcpp::String> param = R_NilValue) {
if (param.isNotNull())
return String(param);
else
return String("");
}
#endif

// [[Rcpp::export]]
void messageWrapper(SEXP s) {
Expand Down
8 changes: 5 additions & 3 deletions inst/tinytest/test_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,11 @@ expect_equal( testNullableIsUsable(M), M)
# test.NullableIsUsableFalse <- function() {
expect_true(is.null(testNullableIsUsable(NULL)))

# test.NullableString <- function() {
expect_equal(testNullableString(), "")
expect_equal(testNullableString("blah"), "blah")
## test.NullableString <- function() {
if (getRversion() > "4.3.0") {
expect_equal(testNullableString(), "")
expect_equal(testNullableString("blah"), "blah")
}

# test.bib <- function() {
expect_true(nchar(Rcpp:::bib()) > 0, info="bib file")
Expand Down