Skip to content

Commit

Permalink
test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Jun 11, 2024
1 parent 2520e51 commit 528f453
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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())

0 comments on commit 528f453

Please sign in to comment.