-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from eddelbuettel/feature/tinytest
use tinytest
- Loading branch information
Showing
11 changed files
with
176 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
## Copyright (C) 2018 - 2019 Dirk Eddelbuettel | ||
## | ||
## This file is part of RcppCCTZ. | ||
## | ||
## RcppCCTZ is free software: you can redistribute it and/or | ||
## modify it under the terms of the GNU General Public License as | ||
## published by the Free Software Foundation, either version 2 of the | ||
## License, or (at your option) any later version. | ||
## | ||
## RcppCCTZ is distributed in the hope that it will be useful, but | ||
## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
## General Public License for more details. | ||
## | ||
## You should have received a copy of the GNU General Public License | ||
## along with RcppCCTZ. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
library(RcppCCTZ) | ||
|
||
timepoint <- ISOdatetime(2010,1,2,3,4,5, tz="UTC") | ||
txt <- formatDatetime(timepoint, tgttzstr="UTC") | ||
expect_equal(txt, "2010-01-02T03:04:05+00:00") | ||
|
||
txt <- formatDouble(as.numeric(timepoint), 0, tgttzstr="UTC") | ||
expect_equal(txt, "2010-01-02T03:04:05+00:00") | ||
|
||
txt <- formatDouble(as.numeric(timepoint), 123456789, tgttzstr="UTC") | ||
expect_equal(txt, "2010-01-02T03:04:05.123456789+00:00") | ||
|
||
timepoint <- ISOdatetime(2010,1,2,3,4,5, tz="UTC") | ||
txt <- RcppCCTZ:::formatDouble(rep(timepoint, 3), c(1001, 2002, 3003)) | ||
vals <- RcppCCTZ:::parseDouble(txt) | ||
c1 <- rep(1262401445, 3) | ||
c2 <- c(1001, 2002, 3003) | ||
expect_equal(vals[,1], c1) | ||
expect_equal(vals[,2], c2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
## Copyright (C) 2018 - 2019 Dirk Eddelbuettel | ||
## | ||
## This file is part of RcppCCTZ. | ||
## | ||
## RcppCCTZ is free software: you can redistribute it and/or | ||
## modify it under the terms of the GNU General Public License as | ||
## published by the Free Software Foundation, either version 2 of the | ||
## License, or (at your option) any later version. | ||
## | ||
## RcppCCTZ is distributed in the hope that it will be useful, but | ||
## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
## General Public License for more details. | ||
## | ||
## You should have received a copy of the GNU General Public License | ||
## along with RcppCCTZ. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
library(RcppCCTZ) | ||
|
||
ds <- getOption("digits.secs") | ||
options(digits.secs=6) # max value | ||
|
||
timepoint <- ISOdatetime(2010,1,2,3,4,5, tz="UTC") | ||
pt <- parseDatetime("2010-01-02 03:04:05", "%Y-%m-%d %H:%M:%S", "UTC") | ||
expect_equal(timepoint, pt) | ||
|
||
pt <- parseDouble("2010-01-02 03:04:05", "%Y-%m-%d %H:%M:%S") | ||
expect_equal(as.numeric(timepoint), pt[1,1]) | ||
|
||
|
||
timepoint <- ISOdatetime(2010,1,2,3,4,5.123456, tz="UTC") | ||
pt <- parseDatetime("2010-01-02 03:04:05.123456", "%Y-%m-%d %H:%M:%E*S", "UTC") | ||
expect_equal(timepoint, pt) | ||
|
||
pt <- parseDouble("2010-01-02 03:04:05.123456", "%Y-%m-%d %H:%M:%E*S") | ||
expect_equal(as.numeric(timepoint), pt[1,1]) | ||
|
||
|
||
timepoints <- ISOdatetime(2010,1,2,3,4,5, tz="UTC") + 0:9 | ||
tpvec <- format(timepoints) | ||
ptvec <- parseDatetime(tpvec, "%Y-%m-%d %H:%M:%S", "UTC") | ||
expect_equal(timepoints, ptvec) | ||
|
||
options(digits.secs=ds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
## Copyright (C) 2018 - 2019 Dirk Eddelbuettel | ||
## | ||
## This file is part of RcppCCTZ. | ||
## | ||
## RcppCCTZ is free software: you can redistribute it and/or | ||
## modify it under the terms of the GNU General Public License as | ||
## published by the Free Software Foundation, either version 2 of the | ||
## License, or (at your option) any later version. | ||
## | ||
## RcppCCTZ is distributed in the hope that it will be useful, but | ||
## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
## General Public License for more details. | ||
## | ||
## You should have received a copy of the GNU General Public License | ||
## along with RcppCCTZ. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
library(RcppCCTZ) | ||
|
||
isSolaris <- Sys.info()[["sysname"]] == "SunOS" | ||
|
||
timepoint <- ISOdatetime(2010,1,2,3,4,5) | ||
if (!isSolaris) { | ||
nyc2lon <- toTz(timepoint, "America/New_York", "Europe/London") | ||
h <- as.integer(difftime(nyc2lon, timepoint, units="hour")) | ||
expect_equal(h, 5L) | ||
} | ||
|
||
moonland <- ISOdatetime(1969,7,20,22,56,0,tz="UTC") | ||
if (!isSolaris) { | ||
oz <- toTz(moonland, "America/New_York", "Australia/Sydney") | ||
txt <- format(oz, tz="Australia/Sydney") | ||
expect_equal(txt, "1969-07-21 12:56:00") | ||
} | ||
|
||
timepoint <- ISOdatetime(2010,1,2,3,4,5) | ||
if (!isSolaris) { | ||
chi2lon <- tzDiff("America/Chicago", "Europe/London", timepoint) | ||
expect_equal(chi2lon, 6L) | ||
|
||
nyc2lon <- tzDiff("America/New_York", "Europe/London", timepoint) | ||
expect_equal(nyc2lon, 5L) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.