Improve graph_copy_test.cc
authorPeter Kovacs <kpeter@inf.elte.hu>
Tue, 22 Jun 2010 16:13:00 +0200
changeset 89424b3f18ed9e2
parent 893 d395358592df
child 895 dca9eed2c375
child 897 e20fecd1945f
child 904 c279b19abc62
Improve graph_copy_test.cc
test/graph_copy_test.cc
     1.1 --- a/test/graph_copy_test.cc	Fri Jun 25 06:41:55 2010 +0200
     1.2 +++ b/test/graph_copy_test.cc	Tue Jun 22 16:13:00 2010 +0200
     1.3 @@ -18,6 +18,7 @@
     1.4  
     1.5  #include <lemon/smart_graph.h>
     1.6  #include <lemon/list_graph.h>
     1.7 +#include <lemon/static_graph.h>
     1.8  #include <lemon/lgf_reader.h>
     1.9  #include <lemon/error.h>
    1.10  
    1.11 @@ -26,6 +27,7 @@
    1.12  using namespace std;
    1.13  using namespace lemon;
    1.14  
    1.15 +template <typename GR>
    1.16  void digraph_copy_test() {
    1.17    const int nn = 10;
    1.18  
    1.19 @@ -51,19 +53,19 @@
    1.20        if (i == 0 && j == 0) fa = arc;
    1.21      }
    1.22    }
    1.23 +  
    1.24 +  // Test digraph copy
    1.25 +  GR to;
    1.26 +  typename GR::template NodeMap<int> tnm(to);
    1.27 +  typename GR::template ArcMap<int> tam(to);
    1.28 +  typename GR::Node tn;
    1.29 +  typename GR::Arc ta;
    1.30  
    1.31 -  // Test digraph copy
    1.32 -  ListDigraph to;
    1.33 -  ListDigraph::NodeMap<int> tnm(to);
    1.34 -  ListDigraph::ArcMap<int> tam(to);
    1.35 -  ListDigraph::Node tn;
    1.36 -  ListDigraph::Arc ta;
    1.37 +  SmartDigraph::NodeMap<typename GR::Node> nr(from);
    1.38 +  SmartDigraph::ArcMap<typename GR::Arc> er(from);
    1.39  
    1.40 -  SmartDigraph::NodeMap<ListDigraph::Node> nr(from);
    1.41 -  SmartDigraph::ArcMap<ListDigraph::Arc> er(from);
    1.42 -
    1.43 -  ListDigraph::NodeMap<SmartDigraph::Node> ncr(to);
    1.44 -  ListDigraph::ArcMap<SmartDigraph::Arc> ecr(to);
    1.45 +  typename GR::template NodeMap<SmartDigraph::Node> ncr(to);
    1.46 +  typename GR::template ArcMap<SmartDigraph::Arc> ecr(to);
    1.47  
    1.48    digraphCopy(from, to).
    1.49      nodeMap(fnm, tnm).arcMap(fam, tam).
    1.50 @@ -86,11 +88,11 @@
    1.51      check(nr[from.target(it)] == to.target(er[it]), "Wrong copy.");
    1.52    }
    1.53  
    1.54 -  for (ListDigraph::NodeIt it(to); it != INVALID; ++it) {
    1.55 +  for (typename GR::NodeIt it(to); it != INVALID; ++it) {
    1.56      check(nr[ncr[it]] == it, "Wrong copy.");
    1.57    }
    1.58  
    1.59 -  for (ListDigraph::ArcIt it(to); it != INVALID; ++it) {
    1.60 +  for (typename GR::ArcIt it(to); it != INVALID; ++it) {
    1.61      check(er[ecr[it]] == it, "Wrong copy.");
    1.62    }
    1.63    check(tn == nr[fn], "Wrong copy.");
    1.64 @@ -103,6 +105,7 @@
    1.65    check(countArcs(from) == countArcs(to), "Wrong copy.");
    1.66  }
    1.67  
    1.68 +template <typename GR>
    1.69  void graph_copy_test() {
    1.70    const int nn = 10;
    1.71  
    1.72 @@ -135,21 +138,21 @@
    1.73    }
    1.74  
    1.75    // Test graph copy
    1.76 -  ListGraph to;
    1.77 -  ListGraph::NodeMap<int> tnm(to);
    1.78 -  ListGraph::ArcMap<int> tam(to);
    1.79 -  ListGraph::EdgeMap<int> tem(to);
    1.80 -  ListGraph::Node tn;
    1.81 -  ListGraph::Arc ta;
    1.82 -  ListGraph::Edge te;
    1.83 +  GR to;
    1.84 +  typename GR::template NodeMap<int> tnm(to);
    1.85 +  typename GR::template ArcMap<int> tam(to);
    1.86 +  typename GR::template EdgeMap<int> tem(to);
    1.87 +  typename GR::Node tn;
    1.88 +  typename GR::Arc ta;
    1.89 +  typename GR::Edge te;
    1.90  
    1.91 -  SmartGraph::NodeMap<ListGraph::Node> nr(from);
    1.92 -  SmartGraph::ArcMap<ListGraph::Arc> ar(from);
    1.93 -  SmartGraph::EdgeMap<ListGraph::Edge> er(from);
    1.94 +  SmartGraph::NodeMap<typename GR::Node> nr(from);
    1.95 +  SmartGraph::ArcMap<typename GR::Arc> ar(from);
    1.96 +  SmartGraph::EdgeMap<typename GR::Edge> er(from);
    1.97  
    1.98 -  ListGraph::NodeMap<SmartGraph::Node> ncr(to);
    1.99 -  ListGraph::ArcMap<SmartGraph::Arc> acr(to);
   1.100 -  ListGraph::EdgeMap<SmartGraph::Edge> ecr(to);
   1.101 +  typename GR::template NodeMap<SmartGraph::Node> ncr(to);
   1.102 +  typename GR::template ArcMap<SmartGraph::Arc> acr(to);
   1.103 +  typename GR::template EdgeMap<SmartGraph::Edge> ecr(to);
   1.104  
   1.105    graphCopy(from, to).
   1.106      nodeMap(fnm, tnm).arcMap(fam, tam).edgeMap(fem, tem).
   1.107 @@ -184,14 +187,14 @@
   1.108            "Wrong copy.");
   1.109    }
   1.110  
   1.111 -  for (ListGraph::NodeIt it(to); it != INVALID; ++it) {
   1.112 +  for (typename GR::NodeIt it(to); it != INVALID; ++it) {
   1.113      check(nr[ncr[it]] == it, "Wrong copy.");
   1.114    }
   1.115  
   1.116 -  for (ListGraph::ArcIt it(to); it != INVALID; ++it) {
   1.117 +  for (typename GR::ArcIt it(to); it != INVALID; ++it) {
   1.118      check(ar[acr[it]] == it, "Wrong copy.");
   1.119    }
   1.120 -  for (ListGraph::EdgeIt it(to); it != INVALID; ++it) {
   1.121 +  for (typename GR::EdgeIt it(to); it != INVALID; ++it) {
   1.122      check(er[ecr[it]] == it, "Wrong copy.");
   1.123    }
   1.124    check(tn == nr[fn], "Wrong copy.");
   1.125 @@ -208,8 +211,11 @@
   1.126  
   1.127  
   1.128  int main() {
   1.129 -  digraph_copy_test();
   1.130 -  graph_copy_test();
   1.131 +  digraph_copy_test<SmartDigraph>();
   1.132 +  digraph_copy_test<ListDigraph>();
   1.133 +  digraph_copy_test<StaticDigraph>();
   1.134 +  graph_copy_test<SmartGraph>();
   1.135 +  graph_copy_test<ListGraph>();
   1.136  
   1.137    return 0;
   1.138  }