tests/testthat/test-utility.R

test_that("prio-grid indicies are from bottom-left to top-right", {
  ncol <- 10
  nrow <- 5
  expect_equal(create_pg_indices(ncol, nrow)[1,1], (ncol*nrow)-ncol+1)
  expect_equal(create_pg_indices(ncol, nrow)[nrow,1], 1)
  expect_equal(create_pg_indices(ncol, nrow)[nrow,ncol], ncol)
  expect_equal(create_pg_indices(ncol, nrow)[1,ncol], ncol*nrow)
})

test_that("prio-grid raster parameters are correct", {
  require(terra)
  expect_equal(ext(prio_blank_grid()) |> as.vector(), options()$PG.options$ext)
  expect_equal(crs(prio_blank_grid()), crs(options()$PG.options$crs))
  expect_equal(ncol(prio_blank_grid()), options()$PG.options$ncol)
  expect_equal(nrow(prio_blank_grid()), options()$PG.options$nrow)
})

test_that("raster_to_pgtibble", {
  pg <- prio_blank_grid()
  names(pg) <- "test"
  expect_s3_class(raster_to_pgtibble(pg), "tbl_df")
})
prio-data/priogrid documentation built on Sept. 25, 2024, 1:18 a.m.