Skip to content

Commit 1bb6e3e

Browse files
+++
1 parent c6a14ab commit 1bb6e3e

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

cpp11test/src/test-doubles.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,22 @@
99

1010
namespace cpp11 {
1111

12-
inline integers as_doubles(SEXP x) {
13-
/*if (TYPEOF(x) == REALSXP) {
14-
return as_cpp<doubles>(x);
15-
} else
16-
*/
17-
if (TYPEOF(x) == INTSXP) {
12+
inline doubles as_doubles(SEXP x) {
13+
if (TYPEOF(x) == REALSXP) {
14+
return as_cpp<doubles>(x);
15+
} else if (TYPEOF(x) == INTSXP) {
1816
integers xn = as_cpp<integers>(x);
19-
return xn;
20-
/*
2117
R_xlen_t len = xn.size();
2218
writable::doubles ret(len);
2319
for (R_xlen_t i = 0; i < len; ++i) {
24-
int el = xn[i];
25-
if (el == NA_INTEGER) {
26-
ret[i] = NA_REAL;
27-
} else {
28-
ret[i] = static_cast<double>(el);
29-
}
20+
int el = xn[i];
21+
if (el == NA_INTEGER) {
22+
ret[i] = NA_REAL;
23+
} else {
24+
ret[i] = static_cast<double>(el);
25+
}
3026
}
3127
return ret;
32-
*/
3328
}
3429

3530
throw type_error(REALSXP, TYPEOF(x));
@@ -409,7 +404,7 @@ context("doubles-C++") {
409404
// cpp11::writable::integers na{NA_INTEGER};
410405
// cpp11::sexp na();
411406

412-
cpp11::integers na3(cpp11::as_doubles(Rf_ScalarInteger(NA_INTEGER)));
407+
cpp11::doubles na3(cpp11::as_doubles(Rf_ScalarInteger(NA_INTEGER)));
413408
expect_true(na3.size() == 1);
414409
// expect_true(ISNA(na3[0]));
415410
// expect_true(cpp11::is_na<double>(na3[0]));

0 commit comments

Comments
 (0)