Skip to content

Commit

Permalink
Minor testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
mhesselbarth committed Oct 23, 2023
1 parent 7a5a0c4 commit 670a942
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 7 additions & 6 deletions tests/testthat/test-reconstruct_pattern.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ testthat::test_that("reconstruct_pattern returns errors", {

testthat::test_that("reconstruct_pattern returns warnings", {

testthat::expect_warning(reconstruct_pattern(pattern = species_a,
n_random = 2, max_runs = 1,
return_input = FALSE, simplify = TRUE),
testthat::expect_warning(reconstruct_pattern(pattern = species_a, n_random = 2,
max_runs = 1, return_input = FALSE,
simplify = TRUE, verbose = FALSE),
regexp = "'simplify = TRUE' not possible for 'n_random > 1'.")

testthat::expect_warning(reconstruct_pattern(pattern = species_a,
n_random = 1, max_runs = 1,
simplify = TRUE),
testthat::expect_warning(reconstruct_pattern(pattern = species_a, n_random = 1,
max_runs = 1, simplify = TRUE,
verbose = FALSE),
regexp = "'simplify = TRUE' not possible for 'return_input = TRUE'.")
})

12 changes: 6 additions & 6 deletions tests/testthat/test-results_habitat_association.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ testthat::test_that("results_habitat_association returns breaks", {
testthat::test_that("results_habitat_association returns warning if significance_threshold is not meaningful", {

testthat::expect_warning(results_habitat_association(raster = landscape_classified$raster,
pattern = random_a,
significance_level = 0.75),
pattern = random_a, significance_level = 0.75,
verbose = FALSE),
regexp = "Make sure 'signifcance_level' is meaningful (e.g. 'significance_level = 0.05').",
fixed = TRUE)
})

testthat::test_that("results_habitat_association returns warning if more than 25 classes are present", {

testthat::expect_warning(results_habitat_association(raster = terra::rast(landscape),
pattern = random_a),
testthat::expect_warning(results_habitat_association(raster = terra::rast(landscape), pattern = random_a,
verbose = FALSE),
regexp = "The raster has more than 25 classes. You can ignore this warning if your raster data is discrete.")

testthat::expect_warning(results_habitat_association(raster = raster_random_cont,
pattern = species_a),
testthat::expect_warning(results_habitat_association(raster = raster_random_cont, pattern = species_a,
verbose = FALSE),
regexp = "The raster has more than 25 classes. You can ignore this warning if your raster data is discrete.")
})

Expand Down

0 comments on commit 670a942

Please sign in to comment.