Skip to content

Commit

Permalink
test(idx_*)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimfalk committed Feb 28, 2024
1 parent 6b0d0eb commit 7d558fb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion R/idx_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#'
#' @examples
#' idx_exists("49125")
#' idx_exists("40477")
idx_exists <- function(x = NULL) {

# debugging ------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion man/idx_exists.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/test-get_idx.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("Extraction of 'INDEX_RC' based on WGS84 coordinates works.", {
sf::st_point(
c(6.104606, 50.768626)
),
crs = 4326
crs = "epsg:4326"
)

expect_equal(get_idx(p1), "143089")
Expand All @@ -16,7 +16,7 @@ test_that("Extraction of 'INDEX_RC' based on ETRS89/UTM32N coordinates works.",
sf::st_point(
c(295840, 5628093)
),
crs = 25832
crs = "epsg:25832"
)

expect_equal(get_idx(p2), "143089")
Expand All @@ -28,7 +28,7 @@ test_that("Extraction of 'INDEX_RC' based on DHDN/GK3 coordinates works.", {
sf::st_point(
c(2507425, 5625914)
),
crs = 31466
crs = "epsg:31466"
)

expect_equal(get_idx(p3), "143089")
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat/test-idx_build.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
test_that("Building of 'INDEX_RC' out of X and Y information works.", {

expect_equal(idx_build(col = 125, row = 49), "49125")
expect_equal(idx_build(col = 0, row = 0), "0")

expect_equal(idx_build(col = 1, row = 0), "1")
expect_equal(idx_build(col = 1, row = 2), "2001")

expect_equal(idx_build(col = 34, row = 36), "36034")
expect_equal(idx_build(col = 125, row = 49), "49125")

expect_equal(idx_build(col = 5, row = 102), "102005")

expect_equal(idx_build(col = 299, row = 299), "299299")
})
8 changes: 7 additions & 1 deletion tests/testthat/test-idx_exists.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
test_that("Sample grid cell is available in the dataset.", {

expect_true(idx_exists("48122"))

expect_true(idx_exists("49125"))

expect_true(idx_exists("224148"))
})

test_that("Random grid cell is not available in the dataset.", {

expect_false(idx_exists("foobar"))
expect_false(idx_exists("0"))

expect_false(idx_exists("40477"))
})

0 comments on commit 7d558fb

Please sign in to comment.