context("Generic tests")
test_that("Sanity checks", {
  expect_error(
    Analogs(expL = 1),
    paste0("Parameter 'expL' must have the dimensions 'lat' and 'lon'"))
  
  expL<- 1 : (2 * 3 * 4 * 5 * 6 * 8)
  dim(expL) <- c(dataset = 2, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 8)
  obsL <- 1 : (1 * 1 * 4 * 5 * 6 * 8)
  dim(obsL) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 8)
  lon <- seq(0, 30, 5)
  lat <- seq(0, 30, 5)
  attr(expL, 'class') <- 's2dv_cube'
  attr(obsL, 'class') <- 's2dv_cube'

  expect_error(
    Analogs(expL = expL, obsL = obsL, criteria = "Large_dist"),
    paste0("parameter 'time_expL' cannot be NULL"))
  
  time_expL=paste("01", "06", "2020", sep = "-")
  expect_error(
  Analogs(expL = expL, obsL = obsL, criteria = "Large_dist",time_expL=time_expL),
  paste0("argument \"time_obsL\" is missing, with no default"))
  
  time_obsL <- paste(rep(1:30,28), rep("6", 28*30), sort(rep(1993 : 2020,30)), sep = "-")
  excludeTime <- 2
  expect_error(
  Analogs(expL = expL, obsL = obsL, criteria = "Large_dist",time_expL=time_expL,
          time_obsL=time_obsL, excludeTime=2),
          paste0("Error in 1:((which(time_obsL %in% time_expL)) - excludeTime) : 
  argument of length 0"))
  
 
  time_expL=paste("1", "6", "2020", sep = "-")
  expect_error(
  Analogs(expL = expL, obsL = obsL, criteria = "Large_dist",time_expL=time_expL,
          time_obsL=time_obsL, excludeTime=2),
  paste0("Error in obsL[, , which(time_obsL %in% time_ref)] : 
    incorrect number of dimensions"))
})