Skip to content

Commit

Permalink
test match_pts_to_graph with dist return for #103
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Sep 4, 2022
1 parent cb4ab14 commit f0fe7ab
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dodgr
Title: Distances on Directed Graphs
Version: 0.2.15.012
Version: 0.2.15.013
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre")),
person("Andreas", "Petutschnig", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"codeRepository": "https://github.com/ATFutures/dodgr",
"issueTracker": "https://github.com/ATFutures/dodgr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.2.15.012",
"version": "0.2.15.013",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
22 changes: 22 additions & 0 deletions tests/testthat/test-match-pts-fns.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,25 @@ test_that ("add nodes to graph", {
expect_true ((nrow (graph1) - nrow (graph0)) > npts)
# actually equals 2 * npts when all edges are bi-directional.
})

test_that ("match with distances", {

graph0 <- weight_streetnet (hampi, wt_profile = "foot")
verts <- dodgr_vertices (graph0)
set.seed (1)
npts <- 10
xy <- data.frame (
x = min (verts$x) + runif (npts) * diff (range (verts$x)),
y = min (verts$y) + runif (npts) * diff (range (verts$y))
)

expect_silent (
res <- match_pts_to_graph (graph0, xy, distances = TRUE)
)
expect_s3_class (res, "data.frame")
expect_equal (ncol (res), 2L)
expect_identical (names (res), c ("index", "d_signed"))
expect_true (length (which (res$d_signed < 0)) > 0L)
expect_true (length (which (res$d_signed > 0)) > 0L)
expect_true (length (which (res$d_signed == 0)) > 0L)
})

0 comments on commit f0fe7ab

Please sign in to comment.