summaryrefslogtreecommitdiff
path: root/src/test/ReachabilityTest.java
blob: 67b29b085e72f66ca81be589eacf88977f27b175 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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));
    }

}