# WARNING - Generated by {fusen} from dev/flat_simulate_treatment.Rmd: do not edit by hand # nolint: line_length_linter.

test_that("update_logreduction_decay works", {
  scenario_example <- create_scenario(
    system.file("input_1culture_2pop.xlsx", package = "ambre")
  )

  result <- purrr::pmap(
    list(
      config = scenario_example$config,
      barrierID = scenario_example$SupplementaryProcessID,
      cropHeight = scenario_example$CropHeight,
      popID = scenario_example$PopulationID,
      decay = scenario_example$nb_day_decay
      
    ),
    function(config, barrierID, cropHeight, popID, decay) {
  
      if (barrierID %in% c(12)) {
  
        update_logreduction_decay(
          config = config,
          cropHeight = cropHeight,
          barrierID = barrierID,
          popID = popID,
          nb_day_decay = decay
        )
  
      } else {
        config
      }
    }
  )
  
  difference_min_value <- scenario_example$config[[2]]$treatment$processes[34, ]$min - result[[2]]$treatment$processes[34, ]$min
  difference_max_value <- scenario_example$config[[2]]$treatment$processes[34, ]$max - result[[2]]$treatment$processes[34, ]$max
  
  expect_equal(object = difference_min_value,
               expected = -3) 
  
  expect_equal(object = difference_max_value,
               expected = -4)
})
