##############################################
  # dat1
  set.seed(1)
  atlano1 <- array(runif(30, -1, 1), 
                   dim = c(dat = 2, sdate = 5, ftime = 3))

  set.seed(2)
  tropano1 <- array(runif(30, -1, 1),
                    dim = c(dat = 2, sdate = 5, ftime = 3))  

  # dat2
  atlano2 <- atlano1
  tropano2 <- tropano1
  atlano2[1, 1, 1] <- NA
  tropano2[1, 1, 1:2] <- NA

##############################################
test_that("1. Input checks", {

  expect_error(
  StatSeasAtlHurr(c(), c()),
  "Parameter 'atlano' and 'tropano' cannot be NULL."
  )
  expect_error(
  StatSeasAtlHurr(c('b'), c('a')),
  "Parameter 'atlano' and 'tropano' must be a numeric array."
  )
  expect_error(
  StatSeasAtlHurr(atlano1, array(1:4, dim = c(2, 2))),
  "Parameter 'atlano' and 'tropano' must have dimension names."
  )
  expect_error(
  StatSeasAtlHurr(array(1:10, dim = c(a = 2, c = 5)), array(1:4, dim = c(a = 2, b = 2))),
  "Parameter 'atlano' and 'tropano' must have same dimension names."
  )
  expect_error(
  StatSeasAtlHurr(array(1:10, dim = c(a = 2, c = 5)), array(1:4, dim = c(c = 5, a = 3))),
  "Parameter 'atlano' and 'tropano' must have the same length of all the dimensions."
  )
  expect_error(
  StatSeasAtlHurr(atlano1, tropano1, hrvar = 1),
  "The parameter 'hrvar' must be either 'HR', 'TC', or 'PDI'."
  )
  expect_error(
  StatSeasAtlHurr(atlano1, tropano1, ncores = 1.5),
  "Parameter 'ncores' must be a positive integer."
  )


})

##############################################
test_that("2. Output checks: dat1", {

expect_equal(
names(StatSeasAtlHurr(atlano1, tropano1)),
c('mean', 'var')
)
expect_equal(
dim(StatSeasAtlHurr(atlano1, tropano1)$mean),
c(dat = 2, sdate = 5, ftime = 3)
)
expect_equal(
dim(StatSeasAtlHurr(atlano1, tropano1)$var),
c(dat = 2, sdate = 5, ftime = 3)
)
expect_equal(
StatSeasAtlHurr(atlano1, tropano1)$mean,
StatSeasAtlHurr(atlano1, tropano1)$var
)
expect_equal(
StatSeasAtlHurr(atlano1, tropano1)$mean[1, 1:2, 2],
c(3.032203, 5.119961),
tolerance = 0.0001
)
expect_equal(
StatSeasAtlHurr(atlano1, tropano1, hrvar = 'TC')$mean,
StatSeasAtlHurr(atlano1, tropano1, hrvar = 'TC')$var
)
expect_equal(
StatSeasAtlHurr(atlano1, tropano1, hrvar = 'PDI')$mean[1, 1:2, 2],
c(0.5664659, 1.7475613),
tolerance = 0.0001
)
expect_equal(
StatSeasAtlHurr(atlano1, tropano1, hrvar = 'PDI')$var[1, 1:2, 2],
c(0.1042551, 0.9922350),
tolerance = 0.0001
)

})

##############################################
test_that("3. Output checks: dat2", {

expect_equal(
StatSeasAtlHurr(atlano2, tropano2)$mean[1, 1:2, 2],
c(NA, 5.119961),
tolerance = 0.0001
)
expect_equal(
StatSeasAtlHurr(atlano2, tropano2)$mean[1, 1, ],
c(NA, NA, 10.84862),
tolerance = 0.0001
)


})
