Commit a60bce6a authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

test(SimGR): add tests when there are NA in Qobs on the whole period or on a sub-period

- add 'testthat' in the 'Suggests' list of the DESCRIPTION file
Refs #44
parent e088b828
Pipeline #26067 passed with stage
in 2 minutes and 3 seconds
......@@ -26,6 +26,7 @@ Imports:
Suggests:
knitr,
rmarkdown,
testthat,
htmlwidgets (>= 1.5.3)
Description: Add-on package to the 'airGR' package that simplifies its use and is aimed at being used for teaching hydrology. The package provides 1) three functions that allow to complete very simply a hydrological modelling exercise 2) plotting functions to help students to explore observed data and to interpret the results of calibration and simulation of the GR ('Génie rural') models 3) a 'Shiny' graphical interface that allows for displaying the impact of model parameters on hydrographs and models internal variables.
License: GPL-2
......
library(testthat)
library(airGRteaching)
test_check("airGRteaching")
context("SimGR")
# --------
data(L0123001, package = "airGR")
BasinObsSubNA <- BasinObs[, c("DatesR", "P", "E", "Qmm", "T")]
BasinObsSubNA[BasinObsSubNA$DatesR >= "1994-01-01", ]$Qmm <- NA
BasinObsTotNA <- BasinObsSubNA[BasinObsSubNA$DatesR >= "1994-01-01", ]
PrepSubNA <- PrepGR(ObsDF = BasinObsSubNA, HydroModel = "GR4J", CemaNeige = FALSE)
PrepTotNA <- PrepGR(ObsDF = BasinObsTotNA, HydroModel = "GR4J", CemaNeige = FALSE)
# --------
test_that("NA on a sub-period", {
expect_message(
object = SimGR(PrepGR = PrepSubNA, Param = c(270.426, 0.984, 108.853, 2.149), EffCrit = "KGE2",
WupPer = c("1994-01-01", "1994-12-31"), SimPer = c("1995-01-01", "1998-12-31"))
,
expected = "\"PrepGR\" does not contain any Qobs values on \"SimPer\". The efficiency criterion is not computed",
)
})
# ----
test_that("NA on the total period", {
expect_warning(
object = SimGR(PrepGR = PrepTotNA, Param = c(270.426, 0.984, 108.853, 2.149), EffCrit = "KGE2",
WupPer = c("1994-01-01", "1994-12-31"), SimPer = c("1995-01-01", "1998-12-31"))
,
expected = "\"PrepGR\" does not contain any Qobs values. The efficiency criterion is not computed",
)
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment