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

test_that("update_logreduction_specific_value 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,
                  matrixID = scenario_example$MatrixID,
                  cropHeight = scenario_example$CropHeight
                ),
                function(config, barrierID, matrixID, cropHeight) {
              
                  if (barrierID %in% c(24, 26, 27, 28) &&
                      matrixID %in% c(3, 5)) {
              
                    update_logreduction_specific_barrier(
                      config = config,
                      cropHeight = cropHeight,
                      barrierID = barrierID
                    )
              
                  } else {
                    config
                  }
                }
              )
  
  difference_min_value <- scenario_example$config[[1]]$treatment$processes[76, ]$min - result[[1]]$treatment$processes[76, ]$min
  difference_max_value <- scenario_example$config[[1]]$treatment$processes[76, ]$max - result[[1]]$treatment$processes[76, ]$max
  
  expect_equal(object = difference_min_value,
               expected = 0) 
  
  expect_equal(object = difference_max_value,
               expected = 0)
  
  difference_min_value <- scenario_example$config[[1]]$treatment$processes[76, ]$min - result[[2]]$treatment$processes[76, ]$min
  difference_max_value <- scenario_example$config[[1]]$treatment$processes[76, ]$max - result[[2]]$treatment$processes[76, ]$max
  
  expect_equal(object = difference_min_value,
               expected = 0)
  
  expect_equal(object = difference_max_value,
               expected = 0)
})
