'update'
[epclust.git] / epclust / tests / testthat / test-filterMA.R
diff --git a/epclust/tests/testthat/test-filterMA.R b/epclust/tests/testthat/test-filterMA.R
new file mode 100644 (file)
index 0000000..8dda50e
--- /dev/null
@@ -0,0 +1,17 @@
+context("filterMA")
+
+test_that("[time-]serie filtering behave as expected",
+{
+       # Currently just a mean of 3 values
+       M = matrix(runif(1000,min=-7,max=7), ncol=10)
+       ref_fM = stats::filter(M, c(1/3,1/3,1/3), circular=FALSE)
+       fM = epclust:::filterMA(M)
+
+       # Expect an agreement on all inner values
+       expect_equal(dim(fM), c(100,10))
+       expect_equal(fM[2:99,], ref_fM[2:99,])
+
+       # Border values should be unchanged
+       expect_equal(fM[1,], M[1,])
+       expect_equal(fM[100,], M[100,])
+})