Skip to content

Commit

Permalink
test: add macb tests
Browse files Browse the repository at this point in the history
references #60, #19
  • Loading branch information
spencerpease committed Sep 8, 2020
1 parent ccf14d6 commit ab6602a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/testthat/test-mcab.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
test_that("MACB works", {

asfr_data <- data.table(
asfr = c(.051, .196, .208, .147, .075, .024, .004),
age_start = seq(15, 45, 5),
age_end = seq(20, 50, 5)
)

asfr_data2 <- data.table(
nfx = c(.2, .2),
age_start = c(20, 25),
age_end = c(25, 30)
)

id_cols <- c("age_start", "age_end")

macb_dt <- macb_from_nfx(asfr_data, id_cols = id_cols, nfx_col = "asfr")
macb_dt2 <- macb_from_nfx(asfr_data2, id_cols = id_cols)

testthat::expect_equal(macb_dt$macb, 28.11702, tolerance = 1e-5)
testthat::expect_equal(macb_dt2$macb, 25)

})

0 comments on commit ab6602a

Please sign in to comment.