Skip to content

Commit

Permalink
fix: balance files use
Browse files Browse the repository at this point in the history
  • Loading branch information
plecharpent committed Feb 22, 2024
1 parent 8d41110 commit 0f178fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/testthat/test-estim_param.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ library(CroptimizR)
library(dplyr)

stics_version <- "V10.0"
#stics_version <- "latest"
javastics_path=file.path(system.file("stics", package = "SticsRTests"),stics_version)
data_dir= file.path(SticsRFiles::download_data(example_dirs="study_case_1", stics_version = stics_version))

Expand Down
13 changes: 9 additions & 4 deletions tests/testthat/test-stics-wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@ model_options= SticsOnR::stics_wrapper_options(javastics=javastics_path, workspa
sim_with_successive_restricted_results=SticsOnR::stics_wrapper(model_options=model_options, situation=c("banana","demo_maize3"))

maize_succ_res <- file(file.path(stics_inputs_path,"demo_maize3","mod_bdemo_maize3.sti"), "rb")
nb_grep_maize <- grep("rotation",readLines(maize_succ_res))
maize_succ_res_lines <- readLines(maize_succ_res)
nb_grep_maize <- grep("rotation", maize_succ_res_lines)
baresoil_succ_res <- file(file.path(stics_inputs_path,"demo_BareSoil2","mod_bdemo_BareSoil2.sti"), "rb")
nb_grep_baresoil <- grep("rotation",readLines(baresoil_succ_res))
baresoil_succ_res_lines <- readLines(baresoil_succ_res)
nb_grep_baresoil <- grep("rotation",baresoil_succ_res_lines)

test_that("Test rotation", {
expect_true(any(grepl("rotation",readLines(file(file.path(stics_inputs_path,"demo_BareSoil2","mod_bdemo_BareSoil2.sti"), "rb")))))
expect_true(any(grepl("rotation",readLines(file(file.path(stics_inputs_path,"demo_maize3","mod_bdemo_maize3.sti"), "rb")))))
expect_true(any(grepl("rotation",maize_succ_res_lines)))
expect_true(any(grepl("rotation",baresoil_succ_res_lines)))
expect_identical(sim_with_successive$sim_list$banana,sim_without_successive$sim_list$banana)
expect_identical(sim_with_successive$sim_list$demo_Wheat1,sim_without_successive$sim_list$demo_Wheat1)
expect_false(identical(sim_with_successive$sim_list$demo_BareSoil2,sim_without_successive$sim_list$demo_BareSoil2))
Expand All @@ -176,3 +178,6 @@ test_that("Test rotation", {

})

close(maize_succ_res)
close(baresoil_succ_res)

0 comments on commit 0f178fd

Please sign in to comment.