tests/testthat/test-extract_points.R

# testthat::context("test-extract_points")

landscape_classified <- classify_habitats(terra::rast(landscape), n = 5, style = "fisher")

points_df <- extract_points(raster = landscape_classified, pattern = species_b)

################################################################################

testthat::test_that("extract_points returns one row for each habitat", {

  testthat::expect_equal(nrow(points_df),
                         expected = 5)
})

testthat::test_that("extract_points counts all points present in the landscape", {

  extracted_points <- sum(points_df$count)

  testthat::expect_equal(extracted_points, expected = species_b$n)
})

Try the shar package in your browser

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

shar documentation built on Oct. 23, 2023, 9:06 a.m.