all set-up to prepare ultimate test before last reports
[talweg.git] / pkg / tests / testthat / test.dateIndexToInteger.R
index 9786097..b2316dd 100644 (file)
@@ -1,26 +1,25 @@
 context("Check that dateIndexToInteger behaves as expected")
 
-test_that("integer index matches date in data",
+test_that("computed integer index is correct; predict_at == 0",
 {
-
-
-
-#TODO: with and without shift at origin (so series values at least forst ones are required)
-
-
-       n = 1500
-       series = list()
-       for (i in seq_len(n))
-       {
-               index = (i%%3) + 1
-               level = mean(s[[index]])
-               serie = s[[index]] - level + rnorm(L,sd=0.05)
-               # 10 series with NAs for index 2
-               if (index == 2 && i >= 60 && i<= 90)
-                       serie[sample(seq_len(L),1)] = NA
-               series[[i]] = list("level"=level,"serie"=serie) #no need for more :: si : time !!!
-       }
-       data = new("Data", data=series)
-
-       dateIndexToInteger = function(index, data)
+       data0 = getData(ts_data="pm10_mesures_H_loc.csv", exo_data="meteo_extra_noNAs.csv",
+               input_tz="Europe/Paris",working_tz="Europe/Paris", predict_at=0, limit=200)
+       expect_identical( dateIndexToInteger("2008-12-10",data), 1 )
+       expect_identical( dateIndexToInteger("2008-12-11",data), 2 )
+       expect_identical( dateIndexToInteger("2008-12-20",data), 11 )
+       expect_identical( dateIndexToInteger("2009-02-01",data), 53 )
+       expect_identical( dateIndexToInteger("2009-03-01",data), 81 )
+       expect_identical( dateIndexToInteger("2009-05-31",data), 172 )
 })
+
+test_that("computed integer index is correct; predict_at > 0",
+{
+       data7 = getData(ts_data="pm10_mesures_H_loc.csv", exo_data="meteo_extra_noNAs.csv",
+               input_tz="Europe/Paris",working_tz="Europe/Paris", predict_at=7, limit=200)
+       expect_identical( dateIndexToInteger("2008-12-10",data), 2 )
+       expect_identical( dateIndexToInteger("2008-12-11",data), 3 )
+       expect_identical( dateIndexToInteger("2008-12-20",data), 12 )
+       expect_identical( dateIndexToInteger("2009-02-01",data), 54 )
+       expect_identical( dateIndexToInteger("2009-03-01",data), 82 )
+       expect_identical( dateIndexToInteger("2009-05-31",data), 173 )
+}