Skip to content

Commit e490d34

Browse files
added unit test
1 parent 11b9f12 commit e490d34

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

inst/NEWS.Rd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
\item The \code{[dpq]nbinom_mu()} scalar functions are now available via
1212
the \code{R::} namespace when R 3.1.2 or newer is used.
1313
\item Add an additional test for AIX before attempting to include \code{execinfo.h}.
14+
\item Rcpp::stop gains a printf like syntax, inspired from the implementation in
15+
Rcpp11, using tinyformat
1416
}
1517
\item Changes in Rcpp Attributes:
1618
\itemize{

inst/unitTests/cpp/misc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,8 @@ StretchyList named_stretchy_list(){
151151
return out;
152152
}
153153

154+
// [[Rcpp::export]]
155+
void test_stop_variadic(){
156+
stop( "%s %d", "foo", 3 ) ;
157+
}
158+

inst/unitTests/runit.misc.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,12 @@ if (.runThisTest) {
139139
pairlist( a = "foo", b = 1L, c = 3.2 )
140140
)
141141
}
142+
143+
test.stop.variadic <- function(){
144+
m <- tryCatch( test_stop_variadic(), error = function(e){
145+
conditionMessage(e)
146+
})
147+
checkEquals( m, "foo 3" )
148+
}
142149

143150
}

0 commit comments

Comments
 (0)