test_that("ageGroupsGen works", {
actual <- ageGroupsGen(0, data.frame("poppercent" = 1, "upperbound" = 2))
expected <- list(
lowerbound = 0, group = list("poppercent" = 1, "upperbound" = 2)
)
expect_equal(actual, expected)
})
test_that("defineDemography works", {
testlist <- list(demography = list())
## With growthRate
expected <- list(
demography = list(
name = "foo",
popSize = 3000L,
maximumAgeYrs = 90,
growthRate = 0.5,
ageGroup = list(
lowerbound = 1,
group = list("poppercent" = 1, "upperbound" = 2)
)
)
)
actual <- defineDemography(
baseList = testlist, name = "foo", popSize = 3000L, maximumAgeYrs = 90,
growthRate = 0.5, lowerbound = 1, poppercent = 1, upperbound = 2
)
expect_equal(actual, expected)
## With placeholders
expected <- list(
demography = list(
name = "foo",
popSize = "@pop@",
maximumAgeYrs = "@maxYears@",
growthRate = "@growthRate@",
ageGroup = list(
lowerbound = "@lowerbound@",
group = list("poppercent" = 1, "upperbound" = 2)
)
)
)
actual <- defineDemography(
baseList = testlist, name = "foo", popSize = "@pop@",
maximumAgeYrs = "@maxYears@", growthRate = "@growthRate@",
lowerbound = "@lowerbound@", poppercent = 1, upperbound = 2
)
expect_equal(actual, expected)
})
test_that("write_demography_compat works", {
testlist <- list(demography = list())
## With placeholders
expected <- list(
demography = list(
name = "foo",
popSize = "@pop@",
maximumAgeYrs = 90,
ageGroup = list(
lowerbound = 0,
group = list("poppercent" = 1, "upperbound" = 2)
)
)
)
actual <- write_demography_compat(
baseList = testlist, country = "foo", pop = "@pop@", percents = 1,
uppers = 2
)
expect_equal(actual, expected)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.