test/graph_test.cc
changeset 228 b6732e0d38c5
parent 209 765619b7cbb2
child 338 49d9a36b3b84
     1.1 --- a/test/graph_test.cc	Fri Jul 18 17:26:12 2008 +0100
     1.2 +++ b/test/graph_test.cc	Mon Jul 21 16:30:28 2008 +0200
     1.3 @@ -24,12 +24,78 @@
     1.4  
     1.5  #include "test_tools.h"
     1.6  #include "graph_test.h"
     1.7 -#include "graph_maps_test.h"
     1.8  
     1.9  using namespace lemon;
    1.10  using namespace lemon::concepts;
    1.11  
    1.12 -void check_concepts() {
    1.13 +template <class Graph>
    1.14 +void checkGraph() {
    1.15 +  TEMPLATE_GRAPH_TYPEDEFS(Graph);
    1.16 +
    1.17 +  Graph G;
    1.18 +  checkGraphNodeList(G, 0);
    1.19 +  checkGraphEdgeList(G, 0);
    1.20 +
    1.21 +  Node
    1.22 +    n1 = G.addNode(),
    1.23 +    n2 = G.addNode(),
    1.24 +    n3 = G.addNode();
    1.25 +  checkGraphNodeList(G, 3);
    1.26 +  checkGraphEdgeList(G, 0);
    1.27 +
    1.28 +  Edge e1 = G.addEdge(n1, n2);
    1.29 +  check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1),
    1.30 +        "Wrong edge");
    1.31 +  checkGraphNodeList(G, 3);
    1.32 +  checkGraphArcList(G, 2);
    1.33 +  checkGraphEdgeList(G, 1);
    1.34 +
    1.35 +  checkGraphOutArcList(G, n1, 1);
    1.36 +  checkGraphOutArcList(G, n2, 1);
    1.37 +  checkGraphOutArcList(G, n3, 0);
    1.38 +
    1.39 +  checkGraphInArcList(G, n1, 1);
    1.40 +  checkGraphInArcList(G, n2, 1);
    1.41 +  checkGraphInArcList(G, n3, 0);
    1.42 +
    1.43 +  checkGraphIncEdgeList(G, n1, 1);
    1.44 +  checkGraphIncEdgeList(G, n2, 1);
    1.45 +  checkGraphIncEdgeList(G, n3, 0);
    1.46 +
    1.47 +  checkGraphConArcList(G, 2);
    1.48 +  checkGraphConEdgeList(G, 1);
    1.49 +
    1.50 +  Edge e2 = G.addEdge(n2, n1), e3 = G.addEdge(n2, n3);
    1.51 +  checkGraphNodeList(G, 3);
    1.52 +  checkGraphArcList(G, 6);
    1.53 +  checkGraphEdgeList(G, 3);
    1.54 +
    1.55 +  checkGraphOutArcList(G, n1, 2);
    1.56 +  checkGraphOutArcList(G, n2, 3);
    1.57 +  checkGraphOutArcList(G, n3, 1);
    1.58 +
    1.59 +  checkGraphInArcList(G, n1, 2);
    1.60 +  checkGraphInArcList(G, n2, 3);
    1.61 +  checkGraphInArcList(G, n3, 1);
    1.62 +
    1.63 +  checkGraphIncEdgeList(G, n1, 2);
    1.64 +  checkGraphIncEdgeList(G, n2, 3);
    1.65 +  checkGraphIncEdgeList(G, n3, 1);
    1.66 +
    1.67 +  checkGraphConArcList(G, 6);
    1.68 +  checkGraphConEdgeList(G, 3);
    1.69 +
    1.70 +  checkArcDirections(G);
    1.71 +
    1.72 +  checkNodeIds(G);
    1.73 +  checkArcIds(G);
    1.74 +  checkEdgeIds(G);
    1.75 +  checkGraphNodeMap(G);
    1.76 +  checkGraphArcMap(G);
    1.77 +  checkGraphEdgeMap(G);
    1.78 +}
    1.79 +
    1.80 +void checkConcepts() {
    1.81    { // Checking graph components
    1.82      checkConcept<BaseGraphComponent, BaseGraphComponent >();
    1.83  
    1.84 @@ -51,14 +117,12 @@
    1.85      checkConcept<ExtendableGraphComponent<>, ListGraph>();
    1.86      checkConcept<ClearableGraphComponent<>, ListGraph>();
    1.87      checkConcept<ErasableGraphComponent<>, ListGraph>();
    1.88 -    checkGraphIterators<ListGraph>();
    1.89    }
    1.90    { // Checking SmartGraph
    1.91      checkConcept<Graph, SmartGraph>();
    1.92      checkConcept<AlterableGraphComponent<>, SmartGraph>();
    1.93      checkConcept<ExtendableGraphComponent<>, SmartGraph>();
    1.94      checkConcept<ClearableGraphComponent<>, SmartGraph>();
    1.95 -    checkGraphIterators<SmartGraph>();
    1.96    }
    1.97  //  { // Checking FullGraph
    1.98  //    checkConcept<Graph, FullGraph>();
    1.99 @@ -71,7 +135,7 @@
   1.100  }
   1.101  
   1.102  template <typename Graph>
   1.103 -void check_graph_validity() {
   1.104 +void checkGraphValidity() {
   1.105    TEMPLATE_GRAPH_TYPEDEFS(Graph);
   1.106    Graph g;
   1.107  
   1.108 @@ -94,7 +158,7 @@
   1.109  }
   1.110  
   1.111  template <typename Graph>
   1.112 -void check_graph_validity_erase() {
   1.113 +void checkGraphValidityErase() {
   1.114    TEMPLATE_GRAPH_TYPEDEFS(Graph);
   1.115    Graph g;
   1.116  
   1.117 @@ -168,20 +232,14 @@
   1.118  //   }
   1.119  // }
   1.120  
   1.121 -void check_graphs() {
   1.122 +void checkGraphs() {
   1.123    { // Checking ListGraph
   1.124      checkGraph<ListGraph>();
   1.125 -    checkGraphNodeMap<ListGraph>();
   1.126 -    checkGraphEdgeMap<ListGraph>();
   1.127 -
   1.128 -    check_graph_validity_erase<ListGraph>();
   1.129 +    checkGraphValidityErase<ListGraph>();
   1.130    }
   1.131    { // Checking SmartGraph
   1.132      checkGraph<SmartGraph>();
   1.133 -    checkGraphNodeMap<SmartGraph>();
   1.134 -    checkGraphEdgeMap<SmartGraph>();
   1.135 -
   1.136 -    check_graph_validity<SmartGraph>();
   1.137 +    checkGraphValidity<SmartGraph>();
   1.138    }
   1.139  //   { // Checking FullGraph
   1.140  //     FullGraph g(5);
   1.141 @@ -197,7 +255,7 @@
   1.142  }
   1.143  
   1.144  int main() {
   1.145 -  check_concepts();
   1.146 -  check_graphs();
   1.147 +  checkConcepts();
   1.148 +  checkGraphs();
   1.149    return 0;
   1.150  }