library(s2dverification)
library(multiApply)
source('/home/Earth/aho/aho-testtest/s2dv/test-compare/Eno/Eno_old.R')
source('/home/Earth/aho/aho-testtest/s2dv/test-compare/Eno/Eno_new.R')
#source('/home/Earth/aho/s2dverification/R/Eno.R')

#test1
  var <- array(1:20, dim = c(2, 4, 5))
  var[1,1,1] <- NA
  res1 <- Eno_new(obs = var, posdim = 2, na.action = na.pass)
  res2 <- Eno_old(obs = var, posdim = 2)

  print("Test 1: ")
  print(all.equal(res1, res2, check.attributes = FALSE))

#test2
  var <- array(rnorm(80), dim = c(1, 2, 4, 10))
  res1 <- Eno_new(obs = var, posdim = 1)
  res2 <- Eno_old(obs = var, posdim = 1)

  print("Test 2: ")
  print(all.equal(res1, res2, check.attributes = FALSE))

#test3
  var <- array(rnorm(80), dim = c(2, 4, 10))
  names(dim(var)) <- c('a', 'b', 'c')
  res1 <- Eno_new(obs = var, posdim = 'a')
  res2 <- Eno_old(obs = var, posdim = 1)

  print("Test 3: ")
  print(all.equal(res1, res2, check.attributes = FALSE))

#test4
  var <- array(rnorm(80), dim = c(2, 4, 10))
  names(dim(var)) <- c('a', 'b', 'c')
  var[1, 1:2, 4] <- NA
  res1 <- Eno_new(obs = var, posdim = 'b', na.action = na.pass)
  res2 <- Eno_old(obs = var, posdim = 2)

  print("Test 4: ")
  print(all.equal(res1, res2, check.attributes = FALSE))


print('All tests pass!')
