From b9a1ccfd0c7ba082a193d50933de52c4eea6a1c0 Mon Sep 17 00:00:00 2001 From: Albert Magyar Date: Tue, 18 Feb 2020 18:29:44 -0800 Subject: Add test case for reachableFrom behavior w.r.t. including root --- src/test/scala/firrtlTests/graph/DiGraphTests.scala | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/graph/DiGraphTests.scala b/src/test/scala/firrtlTests/graph/DiGraphTests.scala index d3553a23..0771460b 100644 --- a/src/test/scala/firrtlTests/graph/DiGraphTests.scala +++ b/src/test/scala/firrtlTests/graph/DiGraphTests.scala @@ -150,4 +150,13 @@ class DiGraphTests extends FirrtlFlatSpec { dotLines.exists(s => s.contains(""""d" -> "k";""")) should be (true) dotLines.exists(s => s.contains("""rankdir="TB";""")) should be (true) } + + "reachableFrom" should "omit the queried node if no self-path exists" in { + degenerateGraph.reachableFrom("a") shouldBe empty + acyclicGraph.reachableFrom("b") should contain theSameElementsAs Vector("d", "e") + } + + "reachableFrom" should "include the queried node if it is included in a cycle" in { + cyclicGraph.reachableFrom("b") should contain theSameElementsAs Vector("a", "b", "c", "d") + } } -- cgit v1.2.3