#include <unit.hpp>
Collaboration diagram for UnitTest:
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::ObservableGraph * | graph |
The test graph. | |
gns::Hierarchy * | hierarchy |
The test hierarchy. | |
gns::View * | view |
The test view. | |
boost::timer | start |
Test starting time. |
|
Testing the basic functionality. Basic tests:
|
|
This connects the nodes of the test graph with random edges. All nodes are connected to each other with a certain propability EDGE_PROB. |
|
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. |
|
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). |
|
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:
The advantage of this method is: it is so simple that the correctness can easily be comprehended. |
|
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. |
|
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. |
|
Setup test case.
|
|
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:
|
|
Cleanup after test case. This is run after every test. The graph, hierarchy and view are deleted. |
|
The test graph.
|
|
The test hierarchy.
|
|
Test starting time.
|
|
The test view.
|