File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1+ 2017-12-03 Dirk Eddelbuettel <edd@debian.org>
2+
3+ * inst/include/Rcpp/sugar/functions/is_na.h: Correct test for NA to work
4+ with new as well as old Date(time)Vectors
5+
6+ * inst/unitTests/cpp/dates.cpp (has_na): Added tests
7+ * inst/unitTests/runit.Date.R (test.NA): Idem
8+
192017-11-30 James J Balamuta <balamut2@illinois.edu>
210
311 * src/attributes.cpp: Fixed missing Rcpp namespace in export interface
Original file line number Diff line number Diff line change @@ -234,3 +234,15 @@ Date test_gmtime(double d) {
234234 Date nd (tm.tm_year , tm.tm_mon + 1 , tm.tm_mday );
235235 return nd;
236236}
237+
238+ // [[Rcpp::export]]
239+ bool has_na_dv (const Rcpp::DateVector d) {
240+ return Rcpp::is_true (Rcpp::any (Rcpp::is_na (d)));
241+ }
242+
243+ // [[Rcpp::export]]
244+ bool has_na_dtv (const Rcpp::DatetimeVector d) {
245+ return Rcpp::is_true (Rcpp::any (Rcpp::is_na (d)));
246+ }
247+
248+
Original file line number Diff line number Diff line change 11# !/usr/bin/env r
22# -*- mode: R; tab-width: 4; -*-
33#
4- # Copyright (C) 2010 - 2016 Dirk Eddelbuettel and Romain Francois
4+ # Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
55#
66# This file is part of Rcpp.
77#
@@ -264,4 +264,16 @@ if (.runThisTest) {
264264 checkEquals(test_gmtime(- 489024000 ), as.Date(" 1954-07-04" ), msg = " Date.test_gmtime.1954" )
265265 Sys.setenv(TZ = oldTZ )
266266 }
267+
268+ test.NA <- function () {
269+ dv <- Sys.Date() + 0 : 2
270+ checkTrue(has_na_dv(dv ) == FALSE , msg = " DateVector.NAtest.withoutNA" )
271+ dv [1 ] <- NA
272+ checkTrue(has_na_dv(dv ) == TRUE , msg = " DateVector.NAtest.withNA" )
273+
274+ dvt <- Sys.time() + 0 : 2
275+ checkTrue(has_na_dtv(dvt ) == FALSE , msg = " DatetimeVector.NAtest.withoutNA" )
276+ dvt [1 ] <- NA
277+ checkTrue(has_na_dtv(dvt ) == TRUE , msg = " DatetimeVector.NAtest.withNA" )
278+ }
267279}
You can’t perform that action at this time.
0 commit comments