Revision: 1783
http://sourceforge.net/p/r-gregmisc/code/1783
Author: warnes
Date: 2014-04-05 01:27:30 +0000 (Sat, 05 Apr 2014)
Log Message:
-----------
- For unit tests, don't check for equality of optional POSIXlt
components. (Bug reported by Brian Ripley).
Modified Paths:
--------------
trunk/gdata/tests/runit.unknown.R
Modified: trunk/gdata/tests/runit.unknown.R
===================================================================
--- trunk/gdata/tests/runit.unknown.R 2014-04-05 01:08:30 UTC (rev 1782)
+++ trunk/gdata/tests/runit.unknown.R 2014-04-05 01:27:30 UTC (rev 1783)
@@ -7,11 +7,10 @@
### {{{ --- Test setup ---
-if(FALSE) {
- library("RUnit")
- library("gdata")
-}
+library("RUnit")
+library("gdata")
+
### {{{ --- Vectors ---
intUnk <- 9999
@@ -332,9 +331,37 @@
## Date-time classes
checkIdentical(unknownToNA(xDateUnk, unknown=dateUnk), xDate)
- checkIdentical(unknownToNA(xPOSIXltUnk, unknown=POSIXltUnk), xPOSIXlt)
checkIdentical(unknownToNA(xPOSIXctUnk, unknown=POSIXctUnk), xPOSIXct)
+ ## Per Brian Ripley on 2014-01-15:
+ ##
+ ## On platforms where POSIXlt has a gmtoff component, it does not need to be set. So
+ ##
+ ## > z$gmtoff
+ ## [1] 3600 NA
+ ## > xPOSIXltUnk$gmtoff
+ ## [1] 3600 3600
+ ##
+ ## (or sometimes 0, not NA).
+ ##
+ ## So although identical() correctly reports that they differ, this
+ ## is allowed for optional components.
+ ##
+ ## It would also be wrong to use identical() to compare isdst
+ ## components: isdst = -1 means unknown.
+ ##
+ tmp_unknownToNA <- unknownToNA(xPOSIXltUnk, unknown=POSIXltUnk)
+ tmp_xPOSIXlt <- xPOSIXlt
+
+ tmp_unknownToNA$gmtoff <- NULL # Remove $gmtoff to avoid comparison
+ tmp_xPOSIXlt$gmtoff <- NULL
+
+ tmp_unknownToNA$isdst <- NULL # Remove $isdst to avoid comparison
+ tmp_xPOSIXlt$isdst <- NULL
+
+ checkIdentical(tmp_unknownToNA, tmp_xPOSIXlt)
+
+
## --- lists and data.frames ---
## with vector of single unknown values
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|