diff --git a/tests/testthat/test-evap.R b/tests/testthat/test-evap.R index dc2d7bc44a96b782bb4c89a432e542a4c9e4f5f5..4f655cfc9e046fc332fe31e74347a05ef2545a77 100644 --- a/tests/testthat/test-evap.R +++ b/tests/testthat/test-evap.R @@ -4,6 +4,7 @@ context("Test evaporation") rm(list = ls()) data(L0123001); BasinObs_L0123001 <- BasinObs data(L0123002); BasinObs_L0123002 <- BasinObs +data(L0123003); BasinObs_L0123003 <- BasinObs comp_evap <- function(BasinObs, Lat, LatUnit, @@ -65,7 +66,8 @@ test_that("PE_Oudin works", { test_that("Inconsitent time series", { skip_on_cran() - warnDaily <- "each day should have only one identical value of julian days. The time series is not sorted, or contains duplicate or missing dates" + msgDaily <- "each day should have only one identical value of julian days. The time series is not sorted, or contains duplicate or missing dates" + msgHoury <- "each day must have 24 identical values of julian days (one for each hour). The time series is not sorted, or contains duplicate or missing dates" # duplicated dates DatesFor1Dupl <- BasinObs_L0123001$DatesR @@ -73,14 +75,22 @@ test_that("Inconsitent time series", { expect_warning(object = PE_Oudin(JD = as.POSIXlt(DatesFor1Dupl)$yday + 1, Temp = BasinObs_L0123001$T, Lat = 0.8, LatUnit = "rad"), - regexp = warnDaily) + regexp = msgDaily) - # not ordered dates + # not ordered daily dates DatesFor1Messy <- sample(BasinObs_L0123001$DatesR) expect_warning(object = PE_Oudin(JD = as.POSIXlt(DatesFor1Messy)$yday + 1, Temp = BasinObs_L0123001$T, Lat = 0.8, LatUnit = "rad"), - regexp = warnDaily) + regexp = msgDaily) + + # not ordered hourly dates + DatesFor3Messy <- sample(BasinObs_L0123003$DatesR) + DatesFor3Messy <- DatesFor3Messy[-5L] + expect_error(object = PE_Oudin(JD = as.POSIXlt(DatesFor3Messy)$yday + 1, + Temp = seq_along(BasinObs_L0123003$T)[-5L], + Lat = 0.8, LatUnit = "rad", TimeStepIn = "hourly"), + regexp = msgHoury, fixed = TRUE) })