Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 5 additions & 41 deletions tests/testthat/test-3-integration_2-LandRCBM_RIA-small.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test_that("Multi module: RIA-small with LandR 2000-2002", {

# Set up project
projectName <- "integration_LandRCBM_RIA-small_2000-2002"
times <- list(start = 2000, end = 2021)
times <- list(start = 2000, end = 2002)

simInitInput <- SpaDEStestMuffleOutput(

Expand Down Expand Up @@ -83,45 +83,9 @@ test_that("Multi module: RIA-small with LandR 2000-2002", {

expect_s4_class(simTest, "simList")


## Check outputs ----

# species ID are correct
expect_equal(head(simTest$cbm_vars$state$species, 5), c(31, 16, 31, 16, 31))
# spatial unit id is correct
expect_true(all(simTest$cbm_vars$state$spatial_unit_id == 42))

# checks for "active" cohorts
with(
list(
ActiveCohortGroups = simTest$cbm_vars$state[gcids != 0, row_idx]
), {
# "Active" cohorts should match the above ground biomass equal to LandR
expect_equal(
simTest$aboveGroundBiomass[,.(Merch = merch, Foliage = foliage, Other = other)],
simTest$cbm_vars$pools[ActiveCohortGroups,.(Merch, Foliage, Other)]
)
expect_equal(
simTest$aboveGroundBiomass$age,
simTest$cbm_vars$state$age[ActiveCohortGroups]
)
}
)
# checks for DOM cohorts
with(
list(
DOMCohortGroups = simTest$cbm_vars$state[gcids == 0, row_idx]
), {
# DOM cohort groups have 0 above ground biomass
expect_true(
all(simTest$cbm_vars$pools[DOMCohortGroups, .(Merch, Foliage, Other)] == 0)
)
# There can't be more than 1 DOM cohort groups per pixel
expect_equal(
length(DOMCohortGroups),
nrow(simTest$cbm_vars$key[row_idx %in% DOMCohortGroups])
)
}
)
# Check outputs
expect_true(!is.null(simTest$emissionsProducts))

})