File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -395,6 +395,34 @@ context("doubles-C++") {
395
395
expect_true (x.at (s0) == 1 );
396
396
}
397
397
398
+ test_that (" operator[] and at with names" ) {
399
+ using namespace cpp11 ::literals;
400
+ cpp11::writable::doubles x ({" a" _nm = 1 ., " b" _nm = 2 .});
401
+ cpp11::doubles y (x);
402
+
403
+ expect_true (x[" a" ] == 1 );
404
+ expect_true (x[" b" ] == 2 );
405
+ expect_error (x[" c" ] == 2 );
406
+
407
+ expect_true (y[" a" ] == 1 );
408
+ expect_true (y[" b" ] == 2 );
409
+ expect_error (y[" c" ] == 2 );
410
+ }
411
+
412
+ test_that (" doubles::find" ) {
413
+ using namespace cpp11 ::literals;
414
+ cpp11::writable::doubles x ({" a" _nm = 1 ., " b" _nm = 2 .});
415
+ cpp11::doubles y (x);
416
+
417
+ expect_true (x.find (" a" ) == x.begin ());
418
+ expect_true (x.find (" b" ) == x.begin () + 1 );
419
+ expect_true (x.find (" c" ) == x.end ());
420
+
421
+ expect_true (y.find (" a" ) == y.begin ());
422
+ expect_true (y.find (" b" ) == y.begin () + 1 );
423
+ expect_true (y.find (" c" ) == y.end ());
424
+ }
425
+
398
426
test_that (" writable::doubles compound assignments" ) {
399
427
cpp11::writable::doubles x (Rf_allocVector (REALSXP, 1 ));
400
428
REAL (x)[0 ] = 1 ;
You can’t perform that action at this time.
0 commit comments