Skip to content

Commit

Permalink
fix: expect_no_error, line length, expected value
Browse files Browse the repository at this point in the history
  • Loading branch information
plecharpent committed Jun 22, 2023
1 parent bf5df93 commit d26a687
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
12 changes: 9 additions & 3 deletions tests/testthat/test-compute_doy_cumul.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ context("Compute DOY sum")


test_that("Compute DOY", {
expect_no_error(SticsRFiles:::compute_doy_cumul(c(350, 360, 10, 20, 30), c( 1990, 1990, 1991, 1991, 1991 )))
expect_error(SticsRFiles:::compute_doy_cumul(c(350, 370, 10, 20, 30), c( 1990, 1990, 1991, 1991, 1991 )))
# expect_error(SticsRFiles:::compute_doy_cumul(c(350, 360, 10, 20, 30), c( 1990, 1990, 1991, 1991, 1992 )))
expect_equal(
compute_doy_cumul(c(350, 360, 10, 20, 30),
c( 1990, 1990, 1991, 1991, 1991 )),
c(350, 360, 375, 385, 395)
)
expect_error(
compute_doy_cumul(c(350, 370, 10, 20, 30),
c( 1990, 1990, 1991, 1991, 1991 ))
)
})
21 changes: 12 additions & 9 deletions tests/testthat/test-gen_varmod.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
library(SticsRFiles)

stics_version <- get_stics_versions_compat()$latest_version
version_num <- SticsRFiles:::get_version_num()

context("Creating a varmod file to latest version")

out_dir <- file.path(tempdir(), "varmod")
if (!dir.exists(out_dir)) dir.create(out_dir)

gen_varmod(out_dir, c("lai(n)", "hauteur"))
gen_varmod(out_dir, "lai(n)")

test_that("Create a varmod file", {
expect_true(file.exists(file.path(out_dir, "var.mod")))
})


gen_varmod(out_dir, "hauteur",append=TRUE)

test_that("Add a new variable", {
expect_true(
grep(pattern = "hauteur",
readLines(file.path(out_dir, "var.mod"))) > 0)
expect_warning(gen_varmod(out_dir, ""))
expect_no_error(gen_varmod(out_dir, "hauteur",append=TRUE))

})
gen_varmod(out_dir, "hauteur",force=TRUE)
test_that("Create a varmod file", {
expect_true(file.exists(file.path(out_dir, "var.mod")))
})

0 comments on commit d26a687

Please sign in to comment.