tests/testthat/test-plot_survival.R

test_that("plotting household survival", {

  test_current_date <- "2020-01-01"
  hm1 <- 
    HouseholdMember$new(
      name       = "member1",
      birth_date = "1955-01-01",
      mode       = 88,
      dispersion = 10.65
    )
  hm2 <- 
    HouseholdMember$new(
      name       = "member2",
      birth_date = "1965-01-01",
      mode       = 91,
      dispersion = 8.88
    )
  hm3 <- 
    HouseholdMember$new(
      name       = "member3",
      birth_date = "1975-01-01",
      mode       = 88,
      dispersion = 7.77
    )
  household <- Household$new()
  household$add_member(hm1)
  household$add_member(hm2)
  household$add_member(hm3) 
  
  plot1 <- function() plot_survival(
    household    = household, 
    current_date = test_current_date
  )
  if (interactive()) print(plot1())
  vdiffr::expect_doppelganger("plot1", plot1)
})

Try the R4GoodPersonalFinances package in your browser

Any scripts or data that you put into this service are public.

R4GoodPersonalFinances documentation built on June 8, 2025, 11:18 a.m.