test-extractDate.R 1.0 KB

123456789101112131415161718192021222324252627
  1. context("position indication")
  2. test_that("position indication works for standard-length products", {
  3. mod13q1 = "MOD13Q1.A2001001.h21v08.006.2015140082121.hdf"
  4. expect_match(extractDate(mod13q1)$inputLayerDates, "^2001001$")
  5. expect_equal(extractDate(mod13q1, asDate = TRUE)$inputLayerDates
  6. , as.Date("2001-01-01"))
  7. })
  8. test_that("position indication works for longer-than-standard products", {
  9. mod15a2h = c("MOD15A2H.A2017001.h21v08.006.2017017150854.hdf"
  10. , "MOD15A2H.A2017001.h21v09.006.2017017150810.hdf")
  11. expect_match(unique(extractDate(mod15a2h)$inputLayerDates), "^2017001$")
  12. expect_equal(unique(extractDate(mod15a2h, asDate = TRUE)$inputLayerDates)
  13. , as.Date("2017-01-01"))
  14. })
  15. test_that("position indication works for shorter-than-standard products", {
  16. mod44b = "MOD44B.A2000065.h00v08.006.2017081101524.hdf"
  17. expect_match(unique(extractDate(mod44b)$inputLayerDates), "^2000065$")
  18. expect_equal(unique(extractDate(mod44b, asDate = TRUE)$inputLayerDates)
  19. , as.Date("2000-03-05"))
  20. })