Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

UnitTest Class Reference

#include <unit.hpp>

Collaboration diagram for UnitTest:

Collaboration graph
[legend]

Detailed Description

Unit test class for testing the view.

This not only tests the view, but also the correctness of the methods of the underlying graph and the hierarchy.


Public Member Functions

void simpleTest ()
 Some first simple tests.
void basicTest ()
 Testing the basic functionality.
void graphChangeTest ()
 Testing changes to the graph.
void expandCollapseTest ()
 Testing the expand and collapse methods of the view.
void buildGraph ()
 This builds a random test graph.
void buildEdges ()
 This connects the nodes of the test graph with random edges.
void buildHierarchy ()
 This builds a hierarchy on top of the graph.
bool checkView ()
 This checks the integrity and correctness of the view.

Protected Member Functions

void setUp (const char *test)
 Setup test case.
void tearDown ()
 Cleanup after test case.

Private Attributes

gns::ObservableGraphgraph
 The test graph.
gns::Hierarchyhierarchy
 The test hierarchy.
gns::Viewview
 The test view.
boost::timer start
 Test starting time.


Member Function Documentation

void basicTest  ) 
 

Testing the basic functionality.

Basic tests:

  • Check number of nodes in graph, hierarchy and view
  • Check if the first graph and hierarchy nodes exist and can be fetched
  • Expand and collapse the View once, check number of nodes, id and properties afterwards
  • Check for correct handling of IDs in the property facility (provoke invalid id exception)
  • Check PropertyIterator and correct types of properties

void buildEdges  ) 
 

This connects the nodes of the test graph with random edges.

All nodes are connected to each other with a certain propability EDGE_PROB.

void buildGraph  ) 
 

This builds a random test graph.

Constructs a graph with GNODE number of nodes. All the nodes get an id which is the number of the node in the order in which they are created.

void buildHierarchy  ) 
 

This builds a hierarchy on top of the graph.

A hierarchy is built atop the graph. The hierarchy has a fixed broadness (e.g.: graph of 10 nodes with broadness 4 would lead to a first level with 2 hierarchy nodes with 4 parents each and 1 hierachy node with 2 parents, and a second level with one hierarchy node with 3 parents (the nodes in level one).

bool checkView  ) 
 

This checks the integrity and correctness of the view.

This checks if there is an edge in the view if and only if there exist at least one edge between one of the descendants of one view node and one of the descendants of the other view node.

This is done in a very time intensive way: For every node in the base graph, a property "vnode" is created containing the view node that either represents the graph node or the ancestor of the graph node which is in the view. Then, for each view node, the following is done:

  • Two std::set<Node>'s: graph_set and view_set are created
  • For every graph node, all outgoing edges are considered and all "vnode" properties of the opposite nodes are inserted into the graph_set
  • For every outgoing view edge, the opposite view node is inserted into the view_set
  • The two set's are checked for equality After this procedure, the "vnode" properties are deleted again.

The advantage of this method is: it is so simple that the correctness can easily be comprehended.

void expandCollapseTest  ) 
 

Testing the expand and collapse methods of the view.

This expands every node in the view, and then collapses all nodes again. After every step, the view is checked for correctness.

void graphChangeTest  ) 
 

Testing changes to the graph.

This sets the view to the third level in the hierarchy (counting top node as first). Then, random changes are applied to the graph (node deletion and insertion with new edges to existing nodes and random connections to hierarchy nodes). After every random change, the view is checked for correctness.

void setUp const char *  test  )  [protected]
 

Setup test case.

void simpleTest  ) 
 

Some first simple tests.

This builds a small predefined graph, a hierarchy and a view and runs a number of small tests to check for basic functionality.

Simple tests:

  • Check ConstGraph::node()
  • Set a property for each edge
  • Create a Hierarchy using a std::vector filled with ConstGraph::node()s and check number of nodes and edges
  • Create a view
  • Expand the view 2 times (it is equal to the base graph then)
  • Collapse the 4th node
  • Delete an edge in the base graph, check for correct number of edges in graph and view
  • Check the edge properties, delete an edge, check the edge properties again
  • Provoke an invalid node id exception and check for correct exception code
  • Provoke an invalid property type exception and check for correct exception code
  • Delete the view, hierarchy and graph

void tearDown  )  [protected]
 

Cleanup after test case.

This is run after every test. The graph, hierarchy and view are deleted.


Field Documentation

gns::ObservableGraph* graph [private]
 

The test graph.

gns::Hierarchy* hierarchy [private]
 

The test hierarchy.

boost::timer start [private]
 

Test starting time.

gns::View* view [private]
 

The test view.


Generated on Sun Nov 5 12:06:20 2006 for Graph by  doxygen 1.4.1