Skip to content

Commit

Permalink
Implement two simple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hsonne committed Apr 18, 2024
1 parent 1678dcb commit 5fd9d72
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
17 changes: 7 additions & 10 deletions tests/testthat/test-function-get_shape_of_german_region.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#
# This test file has been generated by kwb.test::create_test_files()
# launched by user hsonne on 2022-09-16 16:40:56.
# Your are strongly encouraged to modify the dummy functions
# so that real cases are tested. You should then delete this comment.
#
#library(testthat)

test_that("get_shape_of_german_region() works", {

f <- kwb.dwd:::get_shape_of_german_region

expect_error(
f()
# argument "name" is missing, with no default
)
expect_error(f())

expect_error(f("no-such-region"), "No such element")

result <- f("berlin")

expect_s3_class(result, "sf")
})
22 changes: 13 additions & 9 deletions tests/testthat/test-function-read_asc_gz_file_into_matrix.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#
# This test file has been generated by kwb.test::create_test_files()
# launched by user hsonne on 2022-09-16 16:43:25.
# Your are strongly encouraged to modify the dummy functions
# so that real cases are tested. You should then delete this comment.
#
#library(testthat)

test_that("read_asc_gz_file_into_matrix() works", {

f <- kwb.dwd:::read_asc_gz_file_into_matrix

expect_error(
f()
# argument "url" is missing, with no default
expect_error(f())

url <- kwb.dwd:::list_grids_germany(
resolution = "monthly",
extension = ".asc.gz",
variable = "evapo_p",
from = "202001",
to = "202001"
)

result <- f(file = url)

expect_true(is.matrix(result))
expect_true("NODATA_value" %in% names(attributes(result)))
})

0 comments on commit 5fd9d72

Please sign in to comment.