Skip to content

Commit

Permalink
Merge branch 'development' into function/set_up_keyring
Browse files Browse the repository at this point in the history
  • Loading branch information
Jennit07 authored Sep 25, 2023
2 parents 7590279 + 53ede24 commit c3f71cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/compute_mid_year_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
compute_mid_year_age <- function(fyyear, dob) {
age_intervals <- lubridate::interval(
start = dob,
end = as.Date(midpoint_fy(fyyear))
end = midpoint_fy(fyyear)
)

ages <- lubridate::as.period(age_intervals)$year
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-compute_mid_year_age.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
test_that("Accurately compute mid year age", {
expect_equal(
compute_mid_year_age("1718", lubridate::make_date("2000")),
phsmethods::age_calculate(
lubridate::make_date("2000"),
lubridate::make_date("2017", 9L, 30L)
)
)
expect_equal(
compute_mid_year_age("2021", lubridate::make_date("1999") + 1:1000),
phsmethods::age_calculate(
lubridate::make_date("1999") + 1:1000,
lubridate::make_date("2020", 9L, 30L)
)
)
})

0 comments on commit c3f71cc

Please sign in to comment.