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
test tweaks
  • Loading branch information
kevinushey committed Jun 11, 2024
commit 528f453910da900d9a9c37a2b5cb41b0d405cd13
10 changes: 4 additions & 6 deletions inst/tinytest/cpp/Vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,13 +888,11 @@ bool CharacterVector_test_equality_crosspolicy(CharacterVector x, Vector<STRSXP,
}

// [[Rcpp::export]]
double NumericVector_test_out_of_bounds_read() {
NumericVector v(3);
return v[5];
double NumericVector_test_out_of_bounds_read(NumericVector v, R_xlen_t i) {
return v[i];
}

// [[Rcpp::export]]
SEXP CharacterVector_test_out_of_bounds_read() {
CharacterVector v(3);
return v[5];
SEXP CharacterVector_test_out_of_bounds_read(CharacterVector v, R_xlen_t i) {
return v[i];
}
7 changes: 5 additions & 2 deletions inst/tinytest/test_vector.R
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,9 @@ expect_equal(data, data2)
expect_true( !CharacterVector_test_equality("foo", "bar") )
expect_true( !CharacterVector_test_equality_crosspolicy("foo", "bar") )

# https://github.com/RcppCore/Rcpp/issues/1308
expect_error(NumericVector_test_out_of_bounds_read(numeric(0), 0))
expect_error(NumericVector_test_out_of_bounds_read(numeric(1), 1))
expect_error(CharacterVector_test_out_of_bounds_read(character(0), 0))
expect_error(CharacterVector_test_out_of_bounds_read(character(1), 1))

expect_error(NumericVector_test_out_of_bounds_read())
expect_error(CharacterVector_test_out_of_bounds_read())