test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_only_p700 - default", {
  test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv")
  data <- read_dual_pam_single_channel_p700_data(test_data_file)

  par <- data$par
  expect_equal(par[1], 0)
  expect_equal(par[2], 6)
  expect_equal(par[3], 16)
  expect_equal(par[4], 29)
  expect_equal(par[5], 80)
  expect_equal(par[6], 152)
  expect_equal(par[7], 208)
  expect_equal(par[8], 364)
  expect_equal(par[9], 581)
  expect_equal(par[10], 913)
  expect_equal(par[11], 1420)
  expect_equal(par[12], 1763)
  expect_equal(par[13], 2199)
  expect_equal(par[14], 2717)
  expect_equal(par[15], 3315)

  yield_1 <- data$yield_1
  expect_equal(yield_1[1], 0.128)
  expect_equal(yield_1[2], 0.852)
  expect_equal(yield_1[3], 0.848)
  expect_equal(yield_1[4], 0.789)
  expect_equal(yield_1[5], 0.729)
  expect_equal(yield_1[6], 0.516)
  expect_equal(yield_1[7], 0.388)
  expect_equal(yield_1[8], 0.318)
  expect_equal(yield_1[9], 0.289)
  expect_equal(yield_1[10], 0.234)
  expect_equal(yield_1[11], 0.180)
  expect_equal(yield_1[12], 0.155)
  expect_equal(yield_1[13], 0.130)
  expect_equal(yield_1[14], 0.103)
  expect_equal(yield_1[15], 0.077)

  yield_2 <- data$yield_2
  expect_equal(yield_2[1], NA_real_)
  expect_equal(yield_2[2], NA_real_)
  expect_equal(yield_2[3], NA_real_)
  expect_equal(yield_2[4], NA_real_)
  expect_equal(yield_2[5], NA_real_)
  expect_equal(yield_2[6], NA_real_)
  expect_equal(yield_2[7], NA_real_)
  expect_equal(yield_2[8], NA_real_)
  expect_equal(yield_2[9], NA_real_)
  expect_equal(yield_2[10], NA_real_)
  expect_equal(yield_2[11], NA_real_)
  expect_equal(yield_2[12], NA_real_)
  expect_equal(yield_2[13], NA_real_)
  expect_equal(yield_2[14], NA_real_)
  expect_equal(yield_2[15], NA_real_)

  etr_1 <- data$etr_1
  expect_equal(etr_1[1], 0.0)
  expect_equal(etr_1[2], 2.147040)
  expect_equal(etr_1[3], 5.698560)
  expect_equal(etr_1[4], 9.610020)
  expect_equal(etr_1[5], 24.4944)
  expect_equal(etr_1[6], 32.94144)
  expect_equal(etr_1[7], 33.895680)
  expect_equal(etr_1[8], 48.61584)
  expect_equal(etr_1[9], 70.52178)
  expect_equal(etr_1[10], 89.72964)
  expect_equal(etr_1[11], 107.352)
  expect_equal(etr_1[12], 114.77130)
  expect_equal(etr_1[13], 120.06540)
  expect_equal(etr_1[14], 117.53742)
  expect_equal(etr_1[15], 107.2071)

  etr_2 <- data$etr_2
  expect_equal(etr_2[1], NA_real_)
  expect_equal(etr_2[2], NA_real_)
  expect_equal(etr_2[3], NA_real_)
  expect_equal(etr_2[4], NA_real_)
  expect_equal(etr_2[5], NA_real_)
  expect_equal(etr_2[6], NA_real_)
  expect_equal(etr_2[7], NA_real_)
  expect_equal(etr_2[8], NA_real_)
  expect_equal(etr_2[9], NA_real_)
  expect_equal(etr_2[10], NA_real_)
  expect_equal(etr_2[11], NA_real_)
  expect_equal(etr_2[12], NA_real_)
  expect_equal(etr_2[13], NA_real_)
  expect_equal(etr_2[14], NA_real_)
  expect_equal(etr_2[15], NA_real_)
})

test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_only_p700 - etr_factor 0.5", {
  test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv")
  data <- read_dual_pam_single_channel_p700_data(test_data_file, etr_factor = 0.5)

  par <- data$par
  expect_equal(par[1], 0)
  expect_equal(par[2], 6)
  expect_equal(par[3], 16)
  expect_equal(par[4], 29)
  expect_equal(par[5], 80)
  expect_equal(par[6], 152)
  expect_equal(par[7], 208)
  expect_equal(par[8], 364)
  expect_equal(par[9], 581)
  expect_equal(par[10], 913)
  expect_equal(par[11], 1420)
  expect_equal(par[12], 1763)
  expect_equal(par[13], 2199)
  expect_equal(par[14], 2717)
  expect_equal(par[15], 3315)

  yield_1 <- data$yield_1
  expect_equal(yield_1[1], 0.128)
  expect_equal(yield_1[2], 0.852)
  expect_equal(yield_1[3], 0.848)
  expect_equal(yield_1[4], 0.789)
  expect_equal(yield_1[5], 0.729)
  expect_equal(yield_1[6], 0.516)
  expect_equal(yield_1[7], 0.388)
  expect_equal(yield_1[8], 0.318)
  expect_equal(yield_1[9], 0.289)
  expect_equal(yield_1[10], 0.234)
  expect_equal(yield_1[11], 0.180)
  expect_equal(yield_1[12], 0.155)
  expect_equal(yield_1[13], 0.130)
  expect_equal(yield_1[14], 0.103)
  expect_equal(yield_1[15], 0.077)

  yield_2 <- data$yield_2
  expect_equal(yield_2[1], NA_real_)
  expect_equal(yield_2[2], NA_real_)
  expect_equal(yield_2[3], NA_real_)
  expect_equal(yield_2[4], NA_real_)
  expect_equal(yield_2[5], NA_real_)
  expect_equal(yield_2[6], NA_real_)
  expect_equal(yield_2[7], NA_real_)
  expect_equal(yield_2[8], NA_real_)
  expect_equal(yield_2[9], NA_real_)
  expect_equal(yield_2[10], NA_real_)
  expect_equal(yield_2[11], NA_real_)
  expect_equal(yield_2[12], NA_real_)
  expect_equal(yield_2[13], NA_real_)
  expect_equal(yield_2[14], NA_real_)
  expect_equal(yield_2[15], NA_real_)

  etr_1 <- data$etr_1
  expect_equal(etr_1[1], 0.0)
  expect_equal(etr_1[2], 1.2780)
  expect_equal(etr_1[3], 3.3920)
  expect_equal(etr_1[4], 5.72025)
  expect_equal(etr_1[5], 14.580)
  expect_equal(etr_1[6], 19.6080)
  expect_equal(etr_1[7], 20.176)
  expect_equal(etr_1[8], 28.938)
  expect_equal(etr_1[9], 41.97725)
  expect_equal(etr_1[10], 53.41050)
  expect_equal(etr_1[11], 63.9)
  expect_equal(etr_1[12], 68.31625)
  expect_equal(etr_1[13], 71.46750)
  expect_equal(etr_1[14], 69.96275)
  expect_equal(etr_1[15], 63.81375)

  etr_2 <- data$etr_2
  expect_equal(etr_2[1], NA_real_)
  expect_equal(etr_2[2], NA_real_)
  expect_equal(etr_2[3], NA_real_)
  expect_equal(etr_2[4], NA_real_)
  expect_equal(etr_2[5], NA_real_)
  expect_equal(etr_2[6], NA_real_)
  expect_equal(etr_2[7], NA_real_)
  expect_equal(etr_2[8], NA_real_)
  expect_equal(etr_2[9], NA_real_)
  expect_equal(etr_2[10], NA_real_)
  expect_equal(etr_2[11], NA_real_)
  expect_equal(etr_2[12], NA_real_)
  expect_equal(etr_2[13], NA_real_)
  expect_equal(etr_2[14], NA_real_)
  expect_equal(etr_2[15], NA_real_)
})

test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_only_p700 - fraction_photosystem > 1", {
  test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv")
  expect_error(read_dual_pam_single_channel_p700_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2))
})

test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_only_p700 - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", {
  test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv")
  data <- read_dual_pam_single_channel_p700_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8)

  par <- data$par
  expect_equal(par[1], 0)
  expect_equal(par[2], 6)
  expect_equal(par[3], 16)
  expect_equal(par[4], 29)
  expect_equal(par[5], 80)
  expect_equal(par[6], 152)
  expect_equal(par[7], 208)
  expect_equal(par[8], 364)
  expect_equal(par[9], 581)
  expect_equal(par[10], 913)
  expect_equal(par[11], 1420)
  expect_equal(par[12], 1763)
  expect_equal(par[13], 2199)
  expect_equal(par[14], 2717)
  expect_equal(par[15], 3315)

  yield_1 <- data$yield_1
  expect_equal(yield_1[1], 0.128)
  expect_equal(yield_1[2], 0.852)
  expect_equal(yield_1[3], 0.848)
  expect_equal(yield_1[4], 0.789)
  expect_equal(yield_1[5], 0.729)
  expect_equal(yield_1[6], 0.516)
  expect_equal(yield_1[7], 0.388)
  expect_equal(yield_1[8], 0.318)
  expect_equal(yield_1[9], 0.289)
  expect_equal(yield_1[10], 0.234)
  expect_equal(yield_1[11], 0.180)
  expect_equal(yield_1[12], 0.155)
  expect_equal(yield_1[13], 0.130)
  expect_equal(yield_1[14], 0.103)
  expect_equal(yield_1[15], 0.077)

  yield_2 <- data$yield_2
  expect_equal(yield_2[1], NA_real_)
  expect_equal(yield_2[2], NA_real_)
  expect_equal(yield_2[3], NA_real_)
  expect_equal(yield_2[4], NA_real_)
  expect_equal(yield_2[5], NA_real_)
  expect_equal(yield_2[6], NA_real_)
  expect_equal(yield_2[7], NA_real_)
  expect_equal(yield_2[8], NA_real_)
  expect_equal(yield_2[9], NA_real_)
  expect_equal(yield_2[10], NA_real_)
  expect_equal(yield_2[11], NA_real_)
  expect_equal(yield_2[12], NA_real_)
  expect_equal(yield_2[13], NA_real_)
  expect_equal(yield_2[14], NA_real_)
  expect_equal(yield_2[15], NA_real_)

  etr_1 <- data$etr_1
  expect_equal(etr_1[1], 0.0)
  expect_equal(etr_1[2], 0.858816)
  expect_equal(etr_1[3], 2.2794240)
  expect_equal(etr_1[4], 3.8440080)
  expect_equal(etr_1[5], 9.797760)
  expect_equal(etr_1[6], 13.1765760)
  expect_equal(etr_1[7], 13.5582720)
  expect_equal(etr_1[8], 19.4463360)
  expect_equal(etr_1[9], 28.208712)
  expect_equal(etr_1[10], 35.891856)
  expect_equal(etr_1[11], 42.94080)
  expect_equal(etr_1[12], 45.908520)
  expect_equal(etr_1[13], 48.02616)
  expect_equal(etr_1[14], 47.014968)
  expect_equal(etr_1[15], 42.88284)

  etr_2 <- data$etr_2
  expect_equal(etr_2[1], NA_real_)
  expect_equal(etr_2[2], NA_real_)
  expect_equal(etr_2[3], NA_real_)
  expect_equal(etr_2[4], NA_real_)
  expect_equal(etr_2[5], NA_real_)
  expect_equal(etr_2[6], NA_real_)
  expect_equal(etr_2[7], NA_real_)
  expect_equal(etr_2[8], NA_real_)
  expect_equal(etr_2[9], NA_real_)
  expect_equal(etr_2[10], NA_real_)
  expect_equal(etr_2[11], NA_real_)
  expect_equal(etr_2[12], NA_real_)
  expect_equal(etr_2[13], NA_real_)
  expect_equal(etr_2[14], NA_real_)
  expect_equal(etr_2[15], NA_real_)
})
