tests/testthat/test-pifMatch.R

context("pifMatch")
library(terra)

lsat_b <- log(lsat)

for(m in c("cor", "sam", "ed")) {
   test_that("pifMatch return classes", {
      expect_is(lb <- pifMatch(lsat_b, lsat, method = m, returnPifMap = TRUE, returnSimMap = TRUE, returnModels = TRUE), "list", info = sprintf("method=%s", m))
      expect_equal(names(lb), c("img", "simMap", "pifMap", "models"))
      expect_is(lb$models$B1_dn, "lm")
      expect_true(all(vapply(lb[2:3],inherits, logical(1), "SpatRaster")))
      expect_is(lb$img, "list")

   })
}

test_that("error messages", {
    expect_error(lb <- pifMatch(lsat_b, lsat, method = "ok", returnPifMap = TRUE, returnSimMap = TRUE, returnModels = TRUE), "method must be one of")
})

Try the RStoolbox package in your browser

Any scripts or data that you put into this service are public.

RStoolbox documentation built on May 29, 2024, 6:34 a.m.