summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorHaidong Ji2020-05-10 16:18:46 -0500
committerHaidong Ji2020-05-10 16:18:46 -0500
commitbc5a6815181068e76316aa4a611647124d18ba48 (patch)
treeaab5f2386523dfb064a51a689310a183f8286016 /src/test
Reachability done. I found it much easier to work with Java than Python. I tried to start with Python but found it difficult to get started.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ReachabilityTest.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ReachabilityTest.java b/src/test/ReachabilityTest.java
new file mode 100644
index 0000000..67b29b0
--- /dev/null
+++ b/src/test/ReachabilityTest.java
@@ -0,0 +1,38 @@
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class ReachabilityTest {
+
+ @Test
+ void test() {
+ ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
+ for (int i = 0; i < 4; i++) {
+ adj.add(new ArrayList<>());
+ }
+
+ adj.get(0).add(1);
+ adj.get(2).add(1);
+ adj.get(3).add(2);
+ adj.get(0).add(3);
+
+ assertEquals(1, Reachability.reach(adj, 0, 3));
+ }
+
+ @Test
+ void test1() {
+ ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
+ for (int i = 0; i < 4; i++) {
+ adj.add(new ArrayList<>());
+ }
+
+ adj.get(0).add(1);
+
+ adj.get(2).add(1);
+
+ assertEquals(0, Reachability.reach(adj, 0, 3));
+ }
+
+} \ No newline at end of file