context("Generic tests")
test_that("Sanity checks", {
  expect_error(
    CST_Calibration(exp = 1),
    c("Parameter 'exp' and 'obs' must be of the class 's2dv_cube', ",
         "as output by CSTools::CST_Load."))
  expect_error(
    CST_Calibration(obs = 1),
    c("argument \"exp\" is missing, with no default"))
 
  library(zeallot)  
  c(exp, obs) %<-% lonlat_data
  expect_equal(length(CST_Calibration(exp = exp, obs = obs)), 9)
  expect_equal(dim(CST_Calibration(exp = exp, obs = obs)$data), dim(exp$data))
  expect_equal(CST_Calibration(exp = exp, obs = obs)$lat, exp$lat)
  expect_equal(CST_Calibration(exp = exp, obs = obs)$lat, obs$lat)
  expect_equal(CST_Calibration(exp = exp, obs = obs)$lon, exp$lon)
  expect_equal(CST_Calibration(exp = exp, obs = obs)$lon, obs$lon)
  expect_error(CST_Calibration(exp = exp, obs = exp),
  c("The length of the dimension 'member' in the component 'data' ",
         "of the parameter 'obs' must be equal to 1."))
  
  exp2 <- exp
  exp2$data[1, 2, 1, 1, 1, 1] <- NA
  expect_warning(CST_Calibration(exp = exp2, obs = obs),
    "Parameter 'exp' contains NA values.")
  
  obs2 <- obs
  obs2$data[1, 1, 2, 1, 1, 1] <- NA
  expect_warning(CST_Calibration(exp = exp, obs = obs2),
    "Parameter 'obs' contains NA values.")
  
  expect_warning(CST_Calibration(exp = exp2, obs = obs2),
    "Parameter 'obs' contains NA values", "Parameter 'exp' contains NA values.")
})  
