-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documents and tests find_snap() fun. Closes #168
- Loading branch information
1 parent
a184f03
commit e88f712
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
context("find_snap function") | ||
|
||
# skips tests on CRAN since they require a specific version of java | ||
testthat::skip_on_cran() | ||
|
||
# load required data and setup r5r_core | ||
|
||
data_path <- system.file("extdata/spo", package = "r5r") | ||
r5r_core <- setup_r5(data_path, verbose = FALSE) | ||
points <- read.csv(file.path(data_path, "spo_hexgrid.csv")) | ||
|
||
|
||
|
||
|
||
|
||
# errors and warnings ----------------------------------------------------- | ||
|
||
|
||
test_that("adequately raises errors", { | ||
|
||
# invalid mode | ||
expect_error( find_snap(r5r_core, points = points, mode = 'AAA') ) | ||
|
||
# invalid r5r_core | ||
expect_error( find_snap(r5r_core='a', points = points, mode = 'WALK') ) | ||
|
||
# invalid r5r_core | ||
expect_error( find_snap(r5r_core=r5r_core, points = 'a', mode = 'WALK') ) | ||
|
||
}) | ||
|
||
|
||
# adequate behavior ------------------------------------------------------ | ||
|
||
|
||
test_that("output is correct", { | ||
|
||
# expected behavior | ||
expect_s3_class( find_snap(r5r_core, points = points, mode = 'WALK'), 'data.table' ) | ||
|
||
}) | ||
|
||
stop_r5(r5r_core) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters