From 66c82d67f941f8c0f3e50e3fd10eb4de9f09d7e8 Mon Sep 17 00:00:00 2001 From: Francesco Nattino Date: Fri, 22 Nov 2024 13:56:23 +0100 Subject: [PATCH] add test to solve --- tests/testthat/test-stroke.R | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-stroke.R b/tests/testthat/test-stroke.R index bb2921f..6855872 100644 --- a/tests/testthat/test-stroke.R +++ b/tests/testthat/test-stroke.R @@ -24,7 +24,6 @@ test_that("a stroke is found in a very simple network", { # p4 # / # p1 - p2 - p3 - expected <- sf::st_sfc(sf::st_linestring(c(p1, p2, p3)), l3) actual <- stroke(sfc) expect_setequal(actual, expected) @@ -144,6 +143,13 @@ test_that("edges are not split if flow_mode is true", { expect_setequal(actual, expected) }) +test_that("a ring is recognized as a stroke also in flow_mode", { + sfc <- sf::st_sfc(l2, l4, l6, l7) + expected <- sf::st_sfc(sf::st_linestring(c(p3, p6, p5, p2, p3))) + actual <- stroke(sfc, flow_mode = TRUE) + expect_setequal(actual, expected) +}) + test_that("strokes can be formed starting from a given edge", { new_l1 <- sf::st_linestring(c(p1, p2, p3)) sfc <- sf::st_sfc(new_l1, l4, l7) @@ -182,3 +188,12 @@ test_that("attributes can't be returned if edge is specified", { expect_error(stroke(sfc, attribute = TRUE, flow_mode = TRUE, from_edge = 3), "from_edge is not compatible with attributes or flow_mode") }) + +test_that("a ring is recognized when from_edge is specified", { + # This is currently an infinite loop + skip_on_ci() + sfc <- sf::st_sfc(l2, l4, l6, l7) + expected <- sf::st_sfc(sf::st_linestring(c(p3, p6, p5, p2, p3))) + actual <- stroke(sfc, from_edge = 1) + expect_setequal(actual, expected) +})