src/test/graph_test.h
changeset 946 c94ef40a22ce
parent 938 70e2886211d5
child 986 e997802b855c
     1.1 --- a/src/test/graph_test.h	Mon Oct 25 13:29:46 2004 +0000
     1.2 +++ b/src/test/graph_test.h	Wed Oct 27 22:38:50 2004 +0000
     1.3 @@ -21,56 +21,64 @@
     1.4  
     1.5  //! \ingroup misc
     1.6  //! \file
     1.7 -//! \brief Some utility to  test graph classes.
     1.8 +//! \brief Some utility and test cases to test graph classes.
     1.9  namespace lemon {
    1.10  
    1.11    template<class Graph> void checkGraphNodeList(Graph &G, int nn)
    1.12 -    {
    1.13 -      typename Graph::NodeIt n(G);
    1.14 -      for(int i=0;i<nn;i++) {
    1.15 -	check(n!=INVALID,"Wrong Node list linking.");
    1.16 -	++n;
    1.17 -      }
    1.18 -      check(n==INVALID,"Wrong Node list linking.");
    1.19 +  {
    1.20 +    typename Graph::NodeIt n(G);
    1.21 +    for(int i=0;i<nn;i++) {
    1.22 +      check(n!=INVALID,"Wrong Node list linking.");
    1.23 +      ++n;
    1.24      }
    1.25 +    check(n==INVALID,"Wrong Node list linking.");
    1.26 +  }
    1.27  
    1.28 -  template<class Graph> void checkGraphEdgeList(Graph &G, int nn)
    1.29 -    {
    1.30 -      typedef typename Graph::EdgeIt EdgeIt;
    1.31 +  template<class Graph>
    1.32 +  void checkGraphEdgeList(Graph &G, int nn)
    1.33 +  {
    1.34 +    typedef typename Graph::EdgeIt EdgeIt;
    1.35  
    1.36 -      EdgeIt e(G);
    1.37 -      for(int i=0;i<nn;i++) {
    1.38 -	check(e!=INVALID,"Wrong Edge list linking.");
    1.39 -	++e;
    1.40 -      }
    1.41 -      check(e==INVALID,"Wrong Edge list linking.");
    1.42 +    EdgeIt e(G);
    1.43 +    for(int i=0;i<nn;i++) {
    1.44 +      check(e!=INVALID,"Wrong Edge list linking.");
    1.45 +      ++e;
    1.46      }
    1.47 +    check(e==INVALID,"Wrong Edge list linking.");
    1.48 +  }
    1.49  
    1.50 -  template<class Graph> void checkGraphOutEdgeList(Graph &G,
    1.51 -						   typename Graph::Node n,
    1.52 -						   int nn)
    1.53 -    {
    1.54 -      typename Graph::OutEdgeIt e(G,n);
    1.55 -      for(int i=0;i<nn;i++) {
    1.56 -	check(e!=INVALID,"Wrong OutEdge list linking.");
    1.57 -	check(n==G.tail(e), "Wrong OutEdge list linking.");
    1.58 -	++e;
    1.59 -      }
    1.60 -      check(e==INVALID,"Wrong OutEdge list linking.");
    1.61 +  template<class Graph> 
    1.62 +  void checkGraphOutEdgeList(Graph &G, typename Graph::Node n, int nn)
    1.63 +  {
    1.64 +    typename Graph::OutEdgeIt e(G,n);
    1.65 +    for(int i=0;i<nn;i++) {
    1.66 +      check(e!=INVALID,"Wrong OutEdge list linking.");
    1.67 +      check(n==G.tail(e), "Wrong OutEdge list linking.");
    1.68 +      ++e;
    1.69      }
    1.70 +    check(e==INVALID,"Wrong OutEdge list linking.");
    1.71 +  }
    1.72  
    1.73 -  template<class Graph> void checkGraphInEdgeList(Graph &G,
    1.74 -						  typename Graph::Node n,
    1.75 -						  int nn)
    1.76 -    {
    1.77 -      typename Graph::InEdgeIt e(G,n);
    1.78 -      for(int i=0;i<nn;i++) {
    1.79 -	check(e!=INVALID,"Wrong InEdge list linking.");
    1.80 -	check(n==G.head(e), "Wrong InEdge list linking.");
    1.81 -	++e;
    1.82 -      }
    1.83 -      check(e==INVALID,"Wrong InEdge list linking.");
    1.84 +  template<class Graph> void 
    1.85 +  checkGraphInEdgeList(Graph &G, typename Graph::Node n, int nn)
    1.86 +  {
    1.87 +    typename Graph::InEdgeIt e(G,n);
    1.88 +    for(int i=0;i<nn;i++) {
    1.89 +      check(e!=INVALID,"Wrong InEdge list linking.");
    1.90 +      check(n==G.head(e), "Wrong InEdge list linking.");
    1.91 +      ++e;
    1.92      }
    1.93 +    check(e==INVALID,"Wrong InEdge list linking.");
    1.94 +  }
    1.95 +
    1.96 +  template <class Graph> 
    1.97 +  void checkGraph() {
    1.98 +    const int num = 5;
    1.99 +    Graph G;
   1.100 +    addPetersen(G, num);
   1.101 +    bidirGraph(G);
   1.102 +    checkBidirPetersen(G, num);
   1.103 +  }
   1.104  
   1.105    ///\file
   1.106    ///\todo Check head(), tail() as well;