From 7d0867e99499101fad9e1423a506c18d2999e27b Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Fri, 18 Sep 2020 10:38:38 -0400 Subject: [PATCH] Add guard for ALTREP support --- cpp11test/src/test-as.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cpp11test/src/test-as.cpp b/cpp11test/src/test-as.cpp index 3de4ef1d..6a3282c3 100644 --- a/cpp11test/src/test-as.cpp +++ b/cpp11test/src/test-as.cpp @@ -239,19 +239,24 @@ context("as_cpp-C++") { UNPROTECT(1); } +#if defined(__APPLE__) && defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0) test_that("as_cpp(ALTREP_INTSXP)") { SEXP r = PROTECT(R_compact_intrange(1, 5)); + expect_true(ALTREP(r)); auto x1 = cpp11::as_cpp>(r); + expect_true(ALTREP(r)); + expect_true(x1.size() == 5); - expect_true(x1[0] == 1); - expect_true(x1[1] == 2); - expect_true(x1[2] == 3); - expect_true(x1[3] == 4); - expect_true(x1[5] == 5); + int expected = 1; + for (int actual : x1) { + expect_true(actual == expected); + ++expected; + } UNPROTECT(1); } +#endif test_that("as_cpp>()") { SEXP r = PROTECT(Rf_allocVector(STRSXP, 3));