Savarese Software Research

com.savarese.algorithms.graph
Class GraphTestCase<V,E extends com.savarese.algorithms.graph.Edge<V,?>>

java.lang.Object
  extended by TestCase
      extended by com.savarese.algorithms.graph.GraphTestCase<V,E>
Direct Known Subclasses:
AdjacencyListTest

public abstract class GraphTestCase<V,E extends com.savarese.algorithms.graph.Edge<V,?>>
extends TestCase

GraphTest tests implementations of the Graph interface.

Author:
Daniel F. Savarese

Field Summary
protected  com.savarese.algorithms.graph.Graph<V,E> _graph_
          A Graph fixture initalized in setUp() by calling _newGraphFixture_().
 
Constructor Summary
GraphTestCase()
           
 
Method Summary
protected abstract  com.savarese.algorithms.graph.Graph<V,E> _newGraphFixture_()
          Creates a new Graph instance for testing.
protected abstract  E[] _populateGraph_()
          Adds a set of test edges to the _graph_ fixture.
protected  void setUp()
          Instantiates _graph_ to use as a fixture for tests.
protected  void tearDown()
          Clears the Graph fixture, removing all its contents so that a subsequent test will not be affected by the previous one.
 void testAdd()
          Tests the add method by adding a set of edges to the graph fixture and seeing if they are contained in the edge set and if their vertices are contained in the vertex set.
 void testClear()
          Tests the clear method by adding a set of edges to the graph fixture and clearing it, seeing if the size is zero.
 void testEdgeSet()
          Tests that edgeSet retuns null and non-null values in appropriate cases.
 void testSize()
          Tests the size method by adding a set of edges to the graph fixture and seeing if the size matches the number of edges added.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_graph_

protected com.savarese.algorithms.graph.Graph<V,E extends com.savarese.algorithms.graph.Edge<V,?>> _graph_
A Graph fixture initalized in setUp() by calling _newGraphFixture_().

Constructor Detail

GraphTestCase

public GraphTestCase()
Method Detail

_newGraphFixture_

protected abstract com.savarese.algorithms.graph.Graph<V,E> _newGraphFixture_()
Creates a new Graph instance for testing.

Returns:
A new Graph instance for testing.

_populateGraph_

protected abstract E[] _populateGraph_()
Adds a set of test edges to the _graph_ fixture.

Returns:
An array containiing the edges added.

setUp

protected void setUp()
Instantiates _graph_ to use as a fixture for tests.


tearDown

protected void tearDown()
Clears the Graph fixture, removing all its contents so that a subsequent test will not be affected by the previous one.


testAdd

public void testAdd()
Tests the add method by adding a set of edges to the graph fixture and seeing if they are contained in the edge set and if their vertices are contained in the vertex set. Technically, edgeSet and vertexSet are tested in the process.


testSize

public void testSize()
Tests the size method by adding a set of edges to the graph fixture and seeing if the size matches the number of edges added.


testClear

public void testClear()
Tests the clear method by adding a set of edges to the graph fixture and clearing it, seeing if the size is zero.


testEdgeSet

public void testEdgeSet()
Tests that edgeSet retuns null and non-null values in appropriate cases.


Savarese Software Research

Copyright © 2004-2005 Savarese Software Research and Daniel F. Savarese. All Rights Reserved.