Skip to content

Commit

Permalink
Minor cleanup of quarter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vspinu committed Oct 22, 2016
1 parent 66bb808 commit 45acc41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Description: Functions to work with date-times and time-spans: fast and user
fun.
Enhances: chron, timeDate, zoo, xts, its, tis, timeSeries,
fts, tseries
Version: 1.6.0
Version: 1.6.0.9000
Depends:
methods,
R (>= 3.0.0)
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,27 @@ test_that("months accessor extracts correct month",{
})

test_that("quarters accessor extracts correct quarter", {
poslt <- as.POSIXlt("2010-11-03 13:45:59", tz = "UTC", format
= "%Y-%m-%d %H:%M:%S")
posct <- as.POSIXct(poslt)
posct <- ymd_hms("2010-11-03 13:45:59")
poslt <- as.POSIXlt(posct)
date <- as.Date(poslt)

expect_that(quarter(poslt), equals(4))
expect_that(quarter(poslt, with_year = TRUE), equals(2010.4))
expect_that(quarter(poslt, fiscal_start = 11), equals(1))
expect_that(quarter(poslt, with_year = TRUE, fiscal_start = -2 ), equals(2011.1))
expect_that(quarter(poslt, with_year = TRUE, fiscal_start = 11 ), equals(2011.1))

expect_that(quarter(posct), equals(4))
expect_that(quarter(posct, with_year = TRUE), equals(2010.4))
expect_that(quarter(posct, fiscal_start = 11), equals(1))
expect_that(quarter(posct, with_year = TRUE, fiscal_start = -2 ), equals(2011.1))
expect_that(quarter(posct, with_year = TRUE, fiscal_start = 11 ), equals(2011.1))

expect_that(quarter(date), equals(4))
expect_that(quarter(date, with_year = TRUE), equals(2010.4))
expect_that(quarter(date, fiscal_start = 11), equals(1))
expect_that(quarter(date, with_year = TRUE, fiscal_start = -2 ), equals(2011.1))
expect_that(quarter(date, with_year = TRUE, fiscal_start = 11 ), equals(2011.1))
})

test_that("years accessor extracts correct year",{
Expand Down

0 comments on commit 45acc41

Please sign in to comment.