1- // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
1+ // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
22//
33// misc.cpp: Rcpp R/C++ interface class library -- misc unit tests
44//
5- // Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois
5+ // Copyright (C) 2013 - 2015 Dirk Eddelbuettel and Romain Francois
66//
77// This file is part of Rcpp.
88//
2020// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
2121
2222#include < Rcpp.h>
23- using namespace Rcpp ;
23+ using namespace Rcpp ;
2424using namespace std ;
2525#include < iostream>
2626#include < fstream>
@@ -34,47 +34,47 @@ class simple {
3434};
3535
3636// [[Rcpp::export]]
37- SEXP symbol_ (){
37+ SEXP symbol_ () {
3838 return LogicalVector::create (
3939 Symbol ( Rf_install (" foobar" ) ) == Rf_install (" foobar" ),
4040 Symbol ( Rf_mkChar (" foobar" ) ) == Rf_install (" foobar" ),
4141 Symbol ( Rf_mkString (" foobar" ) ) == Rf_install (" foobar" ),
4242 Symbol ( " foobar" ) == Rf_install (" foobar" )
43- ) ;
43+ );
4444}
4545
4646// [[Rcpp::export]]
47- Symbol symbol_ctor (SEXP x){ return Symbol (x); }
47+ Symbol symbol_ctor (SEXP x) { return Symbol (x); }
4848
4949// [[Rcpp::export]]
50- List Argument_ (){
50+ List Argument_ () {
5151 Argument x (" x" ), y (" y" );
5252 return List::create ( x = 2 , y = 3 );
5353}
5454
5555// [[Rcpp::export]]
56- int Dimension_const ( SEXP ia ){
56+ int Dimension_const ( SEXP ia ) {
5757 simple ss (ia);
58- return ss.nrow ();
58+ return ss.nrow ();
5959}
6060
6161// [[Rcpp::export]]
62- SEXP evaluator_error (){
63- return Rcpp_eval ( Rf_lang2 ( Rf_install (" stop" ), Rf_mkString ( " boom" ) ) ) ;
62+ SEXP evaluator_error () {
63+ return Rcpp_eval ( Rf_lang2 ( Rf_install (" stop" ), Rf_mkString ( " boom" ) ) );
6464}
6565
6666// [[Rcpp::export]]
67- SEXP evaluator_ok (SEXP x){
68- return Rcpp_eval ( Rf_lang2 ( Rf_install (" sample" ), x ) ) ;
67+ SEXP evaluator_ok (SEXP x) {
68+ return Rcpp_eval ( Rf_lang2 ( Rf_install (" sample" ), x ) );
6969}
7070
7171// [[Rcpp::export]]
72- void exceptions_ (){
73- throw std::range_error (" boom" ) ;
72+ void exceptions_ () {
73+ throw std::range_error (" boom" );
7474}
7575
7676// [[Rcpp::export]]
77- LogicalVector has_iterator_ ( ){
77+ LogicalVector has_iterator_ ( ) {
7878 return LogicalVector::create (
7979 (bool )Rcpp::traits::has_iterator< std::vector<int > >::value,
8080 (bool )Rcpp::traits::has_iterator< std::list<int > >::value,
@@ -87,7 +87,7 @@ LogicalVector has_iterator_( ){
8787}
8888
8989// [[Rcpp::export]]
90- void test_rcout (std::string tfile, std::string teststring){
90+ void test_rcout (std::string tfile, std::string teststring) {
9191 // define and open testfile
9292 std::ofstream testfile (tfile.c_str ());
9393
@@ -108,8 +108,8 @@ void test_rcout(std::string tfile, std::string teststring){
108108}
109109
110110// [[Rcpp::export]]
111- LogicalVector na_proxy (){
112- CharacterVector s (" foo" ) ;
111+ LogicalVector na_proxy () {
112+ CharacterVector s (" foo" );
113113 return LogicalVector::create (
114114 NA_REAL == NA,
115115 NA_INTEGER == NA,
@@ -130,29 +130,49 @@ LogicalVector na_proxy(){
130130 NA == 12 ,
131131 NA == " foo" ,
132132 NA == s[0 ]
133- ) ;
133+ );
134134}
135135
136136// [[Rcpp::export]]
137- StretchyList stretchy_list (){
138- StretchyList out ;
139- out.push_back ( 1 ) ;
140- out.push_front ( " foo" ) ;
141- out.push_back ( 3.2 ) ;
137+ StretchyList stretchy_list () {
138+ StretchyList out;
139+ out.push_back ( 1 );
140+ out.push_front ( " foo" );
141+ out.push_back ( 3.2 );
142142 return out;
143143}
144144
145145// [[Rcpp::export]]
146- StretchyList named_stretchy_list (){
147- StretchyList out ;
148- out.push_back ( _[" b" ] = 1 ) ;
149- out.push_front ( _[" a" ] = " foo" ) ;
150- out.push_back ( _[" c" ] = 3.2 ) ;
146+ StretchyList named_stretchy_list () {
147+ StretchyList out;
148+ out.push_back ( _[" b" ] = 1 );
149+ out.push_front ( _[" a" ] = " foo" );
150+ out.push_back ( _[" c" ] = 3.2 );
151151 return out;
152152}
153153
154154// [[Rcpp::export]]
155- void test_stop_variadic (){
156- stop ( " %s %d" , " foo" , 3 ) ;
155+ void test_stop_variadic () {
156+ stop ( " %s %d" , " foo" , 3 );
157+ }
158+
159+ // [[Rcpp::export]]
160+ bool testNullableForNull (Nullable N) {
161+ return N.isNull ();
162+ }
163+
164+ // [[Rcpp::export]]
165+ bool testNullableForNotNull (Nullable N) {
166+ return N.isNotNull ();
167+ }
168+
169+ // [[Rcpp::export]]
170+ SEXP testNullableOperator (Nullable N) {
171+ return N;
172+ }
173+
174+ // [[Rcpp::export]]
175+ SEXP testNullableGet (Nullable N) {
176+ return N.get ();
157177}
158178
0 commit comments