diff --git a/R/date-atus.R b/R/date-atus.R index ee27fb6..9c5c8ab 100644 --- a/R/date-atus.R +++ b/R/date-atus.R @@ -1,7 +1,7 @@ #' Calculate Date of Accumulated Thermal Units (ATUs) #' #' Calculates the date on which a specified number of Accumulated Thermal Units (ATUs) -#' are exceeded. +#' are meet or exceeded. #' #' @inheritParams params #' @return A tibble with four columns `year`, `start_date`, `end_date` and `atus`. diff --git a/man/date_atus.Rd b/man/date_atus.Rd index c49b51b..02c6818 100644 --- a/man/date_atus.Rd +++ b/man/date_atus.Rd @@ -24,7 +24,7 @@ A tibble with four columns \code{year}, \code{start_date}, \code{end_date} and \ } \description{ Calculates the date on which a specified number of Accumulated Thermal Units (ATUs) -are exceeded. +are meet or exceeded. } \examples{ date_atus(gsdd::temperature_data) diff --git a/tests/testthat/_snaps/date-atus.md b/tests/testthat/_snaps/date-atus.md index e817980..f991266 100644 --- a/tests/testthat/_snaps/date-atus.md +++ b/tests/testthat/_snaps/date-atus.md @@ -154,3 +154,25 @@ 1 2019 1972-01-01 NA NA +# date_atus picks correct day to exceed 20 + + Code + date_atus + Output + # A tibble: 1 x 4 + # Groups: year [1] + year start_date end_date atus + + 1 2019 1972-01-01 1972-01-02 20 + +# date_atus picks correct day to exceed 600 + + Code + date_atus + Output + # A tibble: 1 x 4 + # Groups: year [1] + year start_date end_date atus + + 1 2019 1972-01-01 1972-01-31 600 + diff --git a/tests/testthat/test-date-atus.R b/tests/testthat/test-date-atus.R index 2b78645..09dad3f 100644 --- a/tests/testthat/test-date-atus.R +++ b/tests/testthat/test-date-atus.R @@ -117,3 +117,33 @@ test_that("date_atus NA if not enough data to reach", { date_atus }) }) + +test_that("date_atus picks correct day to exceed 20", { + data <- tibble::tibble( + date = seq.Date( + from = as.Date("2019-01-01"), + to = as.Date("2019-12-31"), + by = "day"), + temperature = c(0, rep(20, 364))) + + date_atus <- date_atus(data, start_date = as.Date("2019-01-01"), atu = 20) + + expect_snapshot({ + date_atus + }) +}) + +test_that("date_atus picks correct day to exceed 600", { + data <- tibble::tibble( + date = seq.Date( + from = as.Date("2019-01-01"), + to = as.Date("2019-12-31"), + by = "day"), + temperature = c(0, rep(20, 364))) + + date_atus <- date_atus(data, start_date = as.Date("2019-01-01"), atu = 600) + + expect_snapshot({ + date_atus + }) +})