[Rcpp-commits] r3793 - in pkg/Rcpp: . debian inst/unitTests src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Oct 7 23:13:15 CEST 2012
Author: edd
Date: 2012-10-07 23:13:14 +0200 (Sun, 07 Oct 2012)
New Revision: 3793
Modified:
pkg/Rcpp/DESCRIPTION
pkg/Rcpp/debian/control
pkg/Rcpp/inst/unitTests/runit.Date.R
pkg/Rcpp/src/Datetime.cpp
Log:
Added a few more tests
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2012-10-07 14:15:28 UTC (rev 3792)
+++ pkg/Rcpp/DESCRIPTION 2012-10-07 21:13:14 UTC (rev 3793)
@@ -30,8 +30,8 @@
to use than the equivalent low-level loop code. The "Rcpp-sugar" vignette
gives an overview of the feature.
.
- Several examples are included, and 800 unit tests in 362 unit test functions
- provide additional usage examples.
+ Several examples are included, and over 800 unit tests in in over 360 unit
+ test functions provide additional usage examples.
.
An earlier version of Rcpp, containing what we now call the 'classic Rcpp
API' was written during 2005 and 2006 by Dominick Samperi. This code has
Modified: pkg/Rcpp/debian/control
===================================================================
--- pkg/Rcpp/debian/control 2012-10-07 14:15:28 UTC (rev 3792)
+++ pkg/Rcpp/debian/control 2012-10-07 21:13:14 UTC (rev 3793)
@@ -36,8 +36,8 @@
to use than the equivalent low-level loop code. The "Rcpp-sugar" vignette
gives an overview of the feature.
.
- Several examples are included, and 800 unit tests in 362 unit test functions
- provide additional usage examples.
+ Several examples are included, and over 800 unit tests in in over 360 unit
+ test functions provide additional usage examples.
.
An earlier version of Rcpp, containing what we now call the 'classic Rcpp
API' was written during 2005 and 2006 by Dominick Samperi. This code has
Modified: pkg/Rcpp/inst/unitTests/runit.Date.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Date.R 2012-10-07 14:15:28 UTC (rev 3792)
+++ pkg/Rcpp/inst/unitTests/runit.Date.R 2012-10-07 21:13:14 UTC (rev 3793)
@@ -80,7 +80,7 @@
v[1] = Date(12,31,2005) ;
return wrap( v );')
- ,"operator_sexp"=list(
+ ,"Datevector_sexp"=list(
signature(),
'DateVector v(2) ;
v[0] = Date(2005,12,31) ;
@@ -136,6 +136,11 @@
'Datetime dt = Datetime(d);
return wrap(dt);')
+ ,"DatetimeVector_ctor"=list(
+ signature(d="DatetimeVector"),
+ 'DatetimeVector dt = DatetimeVector(d);
+ return wrap(dt);')
+
)
}
@@ -225,7 +230,7 @@
}
test.DateVector.operator.SEXP <- function(){
- fun <- .Rcpp.Date$operator_sexp
+ fun <- .Rcpp.Date$Datevector_sexp
checkEquals(fun(), rep(as.Date("2005-12-31"),2), msg = "DateVector.SEXP")
}
@@ -277,9 +282,10 @@
test.Datetime.ctor.notFinite <- function() {
fun <- .Rcpp.Date$Datetime_ctor_sexp
- checkEquals(fun(NA), as.POSIXct(NA, origin="1970-01-01"), msg = "Datetime.ctor.na")
- checkEquals(fun(NaN), as.POSIXct(NaN, origin="1970-01-01"), msg = "Datetime.ctor.nan")
- checkEquals(fun(Inf), as.POSIXct(Inf, origin="1970-01-01"), msg = "Datetime.ctor.inf")
+ posixtNA <- as.POSIXct(NA, origin="1970-01-01")
+ checkEquals(fun(NA), posixtNA, msg = "Datetime.ctor.na")
+ checkEquals(fun(NaN), posixtNA, msg = "Datetime.ctor.nan")
+ checkEquals(fun(Inf), posixtNA, msg = "Datetime.ctor.inf")
}
test.Datetime.ctor.diffs <- function() {
@@ -290,3 +296,12 @@
checkEquals(as.numeric(difftime(fun(now+0.250), fun(now), units="sec")), 0.250, msg = "Datetime.ctor.diff.0250")
checkEquals(as.numeric(difftime(fun(now+2.500), fun(now), units="sec")), 2.500, msg = "Datetime.ctor.diff.2500")
}
+
+test.zzzDatetimeVector.ctor <- function() {
+ fun <- .Rcpp.Date$DatetimeVector_ctor
+ now <- Sys.time()
+ checkEquals(fun(now + (0:4)*60), now+(0:4)*60, msg = "Datetime.ctor.sequence")
+ vec <- c(now, NA, NaN, Inf, now+2.345)
+ posixtNA <- as.POSIXct(NA, origin="1970-01-01")
+ checkEquals(fun(vec), c(now, rep(posixtNA, 3), now+2.345), msg = "Datetime.ctor.set")
+}
Modified: pkg/Rcpp/src/Datetime.cpp
===================================================================
--- pkg/Rcpp/src/Datetime.cpp 2012-10-07 14:15:28 UTC (rev 3792)
+++ pkg/Rcpp/src/Datetime.cpp 2012-10-07 21:13:14 UTC (rev 3793)
@@ -73,6 +73,7 @@
// m_us is fractional (micro)secs as diff. between (fractional) m_dt and m_tm
m_us = static_cast<int>(::Rf_fround( (m_dt - t) * 1.0e6, 0.0));
} else {
+ m_dt = NA_REAL; // NaN and Inf need it set
m_tm.tm_sec = m_tm.tm_min = m_tm.tm_hour = m_tm.tm_isdst = NA_INTEGER;
m_tm.tm_min = m_tm.tm_hour = m_tm.tm_mday = m_tm.tm_mon = m_tm.tm_year = NA_INTEGER;
m_us = NA_INTEGER;
More information about the Rcpp-commits
mailing list