Skip to content

Commit

Permalink
add tests for atu day picking with simplified data
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahLy9 committed Jul 10, 2024
1 parent 1246652 commit 7b0a037
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/_snaps/date-atus.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,25 @@
<int> <date> <date> <dbl>
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
<int> <date> <date> <dbl>
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
<int> <date> <date> <dbl>
1 2019 1972-01-01 1972-01-31 600

30 changes: 30 additions & 0 deletions tests/testthat/test-date-atus.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})

0 comments on commit 7b0a037

Please sign in to comment.