test-vignettes.R 1.91 KB
Newer Older
1
2
3
context("Test vignette chunks")

test_that("V01_get_started works", {
4
  skip_on_cran()
5
  rm(list = ls())
6
  expect_true(RunVignetteChunks("V01_get_started"))
7
  TestQmmQlsConversion(BasinObs, BasinInfo$BasinArea)
8
9
10
})

test_that("V02.1_param_optim works", {
11
  skip_on_cran()
12
  rm(list = ls())
13
14
15
  load(system.file("vignettesData/vignetteParamOptim.rda", package = "airGR"))
  rda_resGLOB <- resGLOB
  rda_resPORT <- resPORT
16
  expect_true(RunVignetteChunks("V02.1_param_optim"))
17
18
  expect_equal(summary(resGLOB), summary(rda_resGLOB), tolerance = 1e-7)
  expect_equal(resGLOB[, -1], rda_resGLOB[, -1], tolerance = 1e-2) # High tolerance due to randomisation in optimisations
19
20
21
})

test_that("V02.2_param_mcmc works", {
22
  skip_on_cran()
23
  rm(list = ls())
24
25
26
  load(system.file("vignettesData/vignetteParamMCMC.rda", package = "airGR"))
  rda_gelRub <- gelRub
  rda_multDRAM <- multDRAM
27
  expect_true(RunVignetteChunks("V02.2_param_mcmc"))
28
29
  expect_equal(gelRub, rda_gelRub, tolerance = 1e-7)
  expect_equal(multDRAM, rda_multDRAM, tolerance = 1e-7)
30
31
32
})

test_that("V03_param_sets_GR4J works", {
33
  skip_on_cran()
34
  rm(list = ls())
35
  expect_true(RunVignetteChunks("V03_param_sets_GR4J"))
36
37
38
})

test_that("V04_cemaneige_hysteresis works", {
39
  skip_on_cran()
40
  rm(list = ls())
41
42
43
44
45
  load(system.file("vignettesData/vignetteCNHysteresis.rda", package = "airGR"))
  rda_OutputsCrit_Cal <- OutputsCrit_Cal
  rda_OutputsCrit_Cal_NoHyst <- OutputsCrit_Cal_NoHyst
  rda_OutputsCrit_Val <- OutputsCrit_Val
  rda_OutputsCrit_Val_NoHyst <- OutputsCrit_Val_NoHyst
46
  expect_true(RunVignetteChunks("V04_cemaneige_hysteresis"))
47
  TestQmmQlsConversion(BasinObs, BasinInfo$BasinArea)
48
49
50
51
  expect_equal(OutputsCrit_Cal, rda_OutputsCrit_Cal, tolerance = 1e-7)
  expect_equal(OutputsCrit_Cal_NoHyst, rda_OutputsCrit_Cal_NoHyst, tolerance = 1e-7)
  expect_equal(OutputsCrit_Val, rda_OutputsCrit_Val, tolerance = 1e-7)
  expect_equal(OutputsCrit_Val_NoHyst, rda_OutputsCrit_Val_NoHyst, tolerance = 1e-7)
52
})