Skip to content

Commit

Permalink
Merge pull request #31 from eddelbuettel/feature/tinytest
Browse files Browse the repository at this point in the history
use tinytest
  • Loading branch information
eddelbuettel committed Aug 3, 2019
2 parents adff107 + 65c87d2 commit a7bc6e6
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ before_install:
- ./run.sh bootstrap

install:
- ./run.sh install_aptget r-cran-rcpp r-cran-runit
- ./run.sh install_aptget r-cran-rcpp r-cran-tinytest

script:
- ./run.sh run_tests
Expand Down
14 changes: 14 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
2019-08-03 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll minor version

* DESCRIPTION (Suggests): Added tinytest
* .travis.yml (install): Install tinytest

* tests/tinytest.R: New test driver using tinytest
* test/doRUnit.R: Removed

* inst/tinytest/test_format.R: Converted from RUnit
* inst/tinytest/test_parse.R: Idem
* inst/tinytest/test_tz.R: Idem

2019-08-02 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll minor version
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: RcppCCTZ
Type: Package
Title: 'Rcpp' Bindings for the 'CCTZ' Library
Version: 0.2.5.1
Date: 2019-08-02
Version: 0.2.5.2
Date: 2019-08-03
Author: Dirk Eddelbuettel
Maintainer: Dirk Eddelbuettel <edd@debian.org>
Description: 'Rcpp' Access to the 'CCTZ' timezone library is provided. 'CCTZ' is
Expand All @@ -12,7 +12,7 @@ Description: 'Rcpp' Access to the 'CCTZ' timezone library is provided. 'CCTZ' is
details.
License: GPL (>= 2)
Imports: Rcpp (>= 0.11.0)
Suggests: RUnit
Suggests: tinytest
LinkingTo: Rcpp
SystemRequirements: A 64-bit POSIX OS such as Linux or OS X with IANA time
zone data in /usr/share/zoneinfo as well as a recent-enough C++11 compiler
Expand Down
37 changes: 37 additions & 0 deletions inst/tinytest/test_format.R
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)
45 changes: 45 additions & 0 deletions inst/tinytest/test_parse.R
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)
44 changes: 44 additions & 0 deletions inst/tinytest/test_tz.R
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)
}
40 changes: 0 additions & 40 deletions inst/unitTests/runit.Format.R

This file was deleted.

49 changes: 0 additions & 49 deletions inst/unitTests/runit.Parse.R

This file was deleted.

48 changes: 0 additions & 48 deletions inst/unitTests/runit.tz.R

This file was deleted.

56 changes: 0 additions & 56 deletions tests/doRUnit.R

This file was deleted.

Loading

0 comments on commit a7bc6e6

Please sign in to comment.