package progs.lib.test;
import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import progs.lib.BFS;
import progs.lib.Graph;
import static progs.lib.Graph.Node;
/**
* @author KRishna Atkuru
*/
@RunWith(JUnit4.class)
public class BFSTest {
@Test
public void graphTest() {
String[] array = new String[]{
" ",
" ",
" ",
};
Graph graph = Graph.fromStringArray(array);
Graph graph2 = Graph.fromStringArray(array);
Assert.assertEquals(graph.getEdgeList(), graph2.getEdgeList());
}
@Test
public void tests() {
String[] array = new String[]{
" ",
" ",
" ",
};
Graph graph = Graph.fromStringArray(array);
Assert.assertEquals(2, new BFS(graph).distanceFrom(new Node(0, 0), new Node(2, 2)));
Assert.assertEquals(2, new BFS(graph).distanceFrom(new Node(0, 0), new Node(0, 2)));
array = new String[]{
" ",
"#",
" "};
graph = Graph.fromStringArray(array);
Assert.assertEquals(10 /*graph size = 3; so 3 * 3 + 1*/,
new BFS(graph).distanceFrom(new Node(0, 0), new Node(2, 0)));
}
}