Skip to content

Commit dc66f93

Browse files
committed
Add an unit tests for the sugar na_omit
1 parent 2cd6f61 commit dc66f93

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

inst/unitTests/cpp/sugar.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ LogicalVector runit_any_isna( NumericVector xx){
216216
return any( is_na( xx ) ) ;
217217
}
218218

219+
// [[Rcpp::export]]
220+
NumericVector runit_na_omit( NumericVector xx ){
221+
return na_omit( xx ) ;
222+
}
223+
219224
// [[Rcpp::export]]
220225
List runit_lapply( IntegerVector xx){
221226
List res = lapply( xx, seq_len );

inst/unitTests/runit.sugar.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,16 @@ if (.runThisTest) {
290290
checkEquals( fx( c(1:5,NA,7:10) ) , TRUE )
291291
}
292292

293+
test.sugar.na_omit.na <- function( ){
294+
fx <- runit_na_omit
295+
checkEquals( fx( c(1:5,NA,7:10) ), fx( c(1:5,7:10) ) )
296+
}
297+
298+
test.sugar.na_omit.nona <- function( ){
299+
fx <- runit_na_omit
300+
checkEquals( fx( c(1:10) ), fx( c(1:10) ) )
301+
}
302+
293303
test.sugar.lapply <- function( ){
294304
fx <- runit_lapply
295305
checkEquals( fx( 1:10 ), lapply( 1:10, seq_len ) )

0 commit comments

Comments
 (0)