Package progs.lib.test

Source Code of progs.lib.test.BFSTest

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)));
  }
}
TOP

Related Classes of progs.lib.test.BFSTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.