test/maps_test.cc
changeset 799 6be1f9bd2ac0
parent 726 3fc2a801c39e
child 877 141f9c0db4a3
     1.1 --- a/test/maps_test.cc	Sun Oct 04 10:15:32 2009 +0200
     1.2 +++ b/test/maps_test.cc	Wed Dec 09 11:14:06 2009 +0100
     1.3 @@ -22,7 +22,11 @@
     1.4  #include <lemon/concept_check.h>
     1.5  #include <lemon/concepts/maps.h>
     1.6  #include <lemon/maps.h>
     1.7 +#include <lemon/list_graph.h>
     1.8  #include <lemon/smart_graph.h>
     1.9 +#include <lemon/adaptors.h>
    1.10 +#include <lemon/dfs.h>
    1.11 +#include <algorithm>
    1.12  
    1.13  #include "test_tools.h"
    1.14  
    1.15 @@ -34,9 +38,22 @@
    1.16  struct B {};
    1.17  
    1.18  class C {
    1.19 -  int x;
    1.20 +  int _x;
    1.21  public:
    1.22 -  C(int _x) : x(_x) {}
    1.23 +  C(int x) : _x(x) {}
    1.24 +  int get() const { return _x; }
    1.25 +};
    1.26 +inline bool operator<(C c1, C c2) { return c1.get() < c2.get(); }
    1.27 +inline bool operator==(C c1, C c2) { return c1.get() == c2.get(); }
    1.28 +
    1.29 +C createC(int x) { return C(x); }
    1.30 +
    1.31 +template <typename T>
    1.32 +class Less {
    1.33 +  T _t;
    1.34 +public:
    1.35 +  Less(T t): _t(t) {}
    1.36 +  bool operator()(const T& t) const { return t < _t; }
    1.37  };
    1.38  
    1.39  class F {
    1.40 @@ -53,6 +70,14 @@
    1.41  
    1.42  int binc(int a, B) { return a+1; }
    1.43  
    1.44 +template <typename T>
    1.45 +class Sum {
    1.46 +  T& _sum;
    1.47 +public:
    1.48 +  Sum(T& sum) : _sum(sum) {}
    1.49 +  void operator()(const T& t) { _sum += t; }
    1.50 +};
    1.51 +
    1.52  typedef ReadMap<A, double> DoubleMap;
    1.53  typedef ReadWriteMap<A, double> DoubleWriteMap;
    1.54  typedef ReferenceMap<A, double, double&, const double&> DoubleRefMap;
    1.55 @@ -329,6 +354,10 @@
    1.56    // LoggerBoolMap
    1.57    {
    1.58      typedef std::vector<int> vec;
    1.59 +    checkConcept<WriteMap<int, bool>, LoggerBoolMap<vec::iterator> >();
    1.60 +    checkConcept<WriteMap<int, bool>,
    1.61 +                 LoggerBoolMap<std::back_insert_iterator<vec> > >();
    1.62 +
    1.63      vec v1;
    1.64      vec v2(10);
    1.65      LoggerBoolMap<std::back_insert_iterator<vec> >
    1.66 @@ -348,6 +377,223 @@
    1.67      for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
    1.68            it != map2.end(); ++it )
    1.69        check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
    1.70 +    
    1.71 +    typedef ListDigraph Graph;
    1.72 +    DIGRAPH_TYPEDEFS(Graph);
    1.73 +    Graph gr;
    1.74 +
    1.75 +    Node n0 = gr.addNode();
    1.76 +    Node n1 = gr.addNode();
    1.77 +    Node n2 = gr.addNode();
    1.78 +    Node n3 = gr.addNode();
    1.79 +    
    1.80 +    gr.addArc(n3, n0);
    1.81 +    gr.addArc(n3, n2);
    1.82 +    gr.addArc(n0, n2);
    1.83 +    gr.addArc(n2, n1);
    1.84 +    gr.addArc(n0, n1);
    1.85 +    
    1.86 +    {
    1.87 +      std::vector<Node> v;
    1.88 +      dfs(gr).processedMap(loggerBoolMap(std::back_inserter(v))).run();
    1.89 +
    1.90 +      check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3,
    1.91 +            "Something is wrong with LoggerBoolMap");
    1.92 +    }
    1.93 +    {
    1.94 +      std::vector<Node> v(countNodes(gr));
    1.95 +      dfs(gr).processedMap(loggerBoolMap(v.begin())).run();
    1.96 +      
    1.97 +      check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3,
    1.98 +            "Something is wrong with LoggerBoolMap");
    1.99 +    }
   1.100 +  }
   1.101 +  
   1.102 +  // IdMap, RangeIdMap
   1.103 +  {
   1.104 +    typedef ListDigraph Graph;
   1.105 +    DIGRAPH_TYPEDEFS(Graph);
   1.106 +
   1.107 +    checkConcept<ReadMap<Node, int>, IdMap<Graph, Node> >();
   1.108 +    checkConcept<ReadMap<Arc, int>, IdMap<Graph, Arc> >();
   1.109 +    checkConcept<ReadMap<Node, int>, RangeIdMap<Graph, Node> >();
   1.110 +    checkConcept<ReadMap<Arc, int>, RangeIdMap<Graph, Arc> >();
   1.111 +    
   1.112 +    Graph gr;
   1.113 +    IdMap<Graph, Node> nmap(gr);
   1.114 +    IdMap<Graph, Arc> amap(gr);
   1.115 +    RangeIdMap<Graph, Node> nrmap(gr);
   1.116 +    RangeIdMap<Graph, Arc> armap(gr);
   1.117 +    
   1.118 +    Node n0 = gr.addNode();
   1.119 +    Node n1 = gr.addNode();
   1.120 +    Node n2 = gr.addNode();
   1.121 +    
   1.122 +    Arc a0 = gr.addArc(n0, n1);
   1.123 +    Arc a1 = gr.addArc(n0, n2);
   1.124 +    Arc a2 = gr.addArc(n2, n1);
   1.125 +    Arc a3 = gr.addArc(n2, n0);
   1.126 +    
   1.127 +    check(nmap[n0] == gr.id(n0) && nmap(gr.id(n0)) == n0, "Wrong IdMap");
   1.128 +    check(nmap[n1] == gr.id(n1) && nmap(gr.id(n1)) == n1, "Wrong IdMap");
   1.129 +    check(nmap[n2] == gr.id(n2) && nmap(gr.id(n2)) == n2, "Wrong IdMap");
   1.130 +
   1.131 +    check(amap[a0] == gr.id(a0) && amap(gr.id(a0)) == a0, "Wrong IdMap");
   1.132 +    check(amap[a1] == gr.id(a1) && amap(gr.id(a1)) == a1, "Wrong IdMap");
   1.133 +    check(amap[a2] == gr.id(a2) && amap(gr.id(a2)) == a2, "Wrong IdMap");
   1.134 +    check(amap[a3] == gr.id(a3) && amap(gr.id(a3)) == a3, "Wrong IdMap");
   1.135 +
   1.136 +    check(nmap.inverse()[gr.id(n0)] == n0, "Wrong IdMap::InverseMap");
   1.137 +    check(amap.inverse()[gr.id(a0)] == a0, "Wrong IdMap::InverseMap");
   1.138 +    
   1.139 +    check(nrmap.size() == 3 && armap.size() == 4,
   1.140 +          "Wrong RangeIdMap::size()");
   1.141 +
   1.142 +    check(nrmap[n0] == 0 && nrmap(0) == n0, "Wrong RangeIdMap");
   1.143 +    check(nrmap[n1] == 1 && nrmap(1) == n1, "Wrong RangeIdMap");
   1.144 +    check(nrmap[n2] == 2 && nrmap(2) == n2, "Wrong RangeIdMap");
   1.145 +    
   1.146 +    check(armap[a0] == 0 && armap(0) == a0, "Wrong RangeIdMap");
   1.147 +    check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap");
   1.148 +    check(armap[a2] == 2 && armap(2) == a2, "Wrong RangeIdMap");
   1.149 +    check(armap[a3] == 3 && armap(3) == a3, "Wrong RangeIdMap");
   1.150 +
   1.151 +    check(nrmap.inverse()[0] == n0, "Wrong RangeIdMap::InverseMap");
   1.152 +    check(armap.inverse()[0] == a0, "Wrong RangeIdMap::InverseMap");
   1.153 +    
   1.154 +    gr.erase(n1);
   1.155 +    
   1.156 +    if (nrmap[n0] == 1) nrmap.swap(n0, n2);
   1.157 +    nrmap.swap(n2, n0);
   1.158 +    if (armap[a1] == 1) armap.swap(a1, a3);
   1.159 +    armap.swap(a3, a1);
   1.160 +    
   1.161 +    check(nrmap.size() == 2 && armap.size() == 2,
   1.162 +          "Wrong RangeIdMap::size()");
   1.163 +
   1.164 +    check(nrmap[n0] == 1 && nrmap(1) == n0, "Wrong RangeIdMap");
   1.165 +    check(nrmap[n2] == 0 && nrmap(0) == n2, "Wrong RangeIdMap");
   1.166 +    
   1.167 +    check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap");
   1.168 +    check(armap[a3] == 0 && armap(0) == a3, "Wrong RangeIdMap");
   1.169 +
   1.170 +    check(nrmap.inverse()[0] == n2, "Wrong RangeIdMap::InverseMap");
   1.171 +    check(armap.inverse()[0] == a3, "Wrong RangeIdMap::InverseMap");
   1.172 +  }
   1.173 +  
   1.174 +  // SourceMap, TargetMap, ForwardMap, BackwardMap, InDegMap, OutDegMap
   1.175 +  {
   1.176 +    typedef ListGraph Graph;
   1.177 +    GRAPH_TYPEDEFS(Graph);
   1.178 +    
   1.179 +    checkConcept<ReadMap<Arc, Node>, SourceMap<Graph> >();
   1.180 +    checkConcept<ReadMap<Arc, Node>, TargetMap<Graph> >();
   1.181 +    checkConcept<ReadMap<Edge, Arc>, ForwardMap<Graph> >();
   1.182 +    checkConcept<ReadMap<Edge, Arc>, BackwardMap<Graph> >();
   1.183 +    checkConcept<ReadMap<Node, int>, InDegMap<Graph> >();
   1.184 +    checkConcept<ReadMap<Node, int>, OutDegMap<Graph> >();
   1.185 +
   1.186 +    Graph gr;
   1.187 +    Node n0 = gr.addNode();
   1.188 +    Node n1 = gr.addNode();
   1.189 +    Node n2 = gr.addNode();
   1.190 +    
   1.191 +    gr.addEdge(n0,n1);
   1.192 +    gr.addEdge(n1,n2);
   1.193 +    gr.addEdge(n0,n2);
   1.194 +    gr.addEdge(n2,n1);
   1.195 +    gr.addEdge(n1,n2);
   1.196 +    gr.addEdge(n0,n1);
   1.197 +    
   1.198 +    for (EdgeIt e(gr); e != INVALID; ++e) {
   1.199 +      check(forwardMap(gr)[e] == gr.direct(e, true), "Wrong ForwardMap");
   1.200 +      check(backwardMap(gr)[e] == gr.direct(e, false), "Wrong BackwardMap");
   1.201 +    }
   1.202 +    
   1.203 +    check(mapCompare(gr,
   1.204 +          sourceMap(orienter(gr, constMap<Edge, bool>(true))),
   1.205 +          targetMap(orienter(gr, constMap<Edge, bool>(false)))),
   1.206 +          "Wrong SourceMap or TargetMap");
   1.207 +
   1.208 +    typedef Orienter<Graph, const ConstMap<Edge, bool> > Digraph;
   1.209 +    Digraph dgr(gr, constMap<Edge, bool>(true));
   1.210 +    OutDegMap<Digraph> odm(dgr);
   1.211 +    InDegMap<Digraph> idm(dgr);
   1.212 +    
   1.213 +    check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 1, "Wrong OutDegMap");
   1.214 +    check(idm[n0] == 0 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap");
   1.215 +   
   1.216 +    gr.addEdge(n2, n0);
   1.217 +
   1.218 +    check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 2, "Wrong OutDegMap");
   1.219 +    check(idm[n0] == 1 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap");
   1.220 +  }
   1.221 +  
   1.222 +  // CrossRefMap
   1.223 +  {
   1.224 +    typedef ListDigraph Graph;
   1.225 +    DIGRAPH_TYPEDEFS(Graph);
   1.226 +
   1.227 +    checkConcept<ReadWriteMap<Node, int>,
   1.228 +                 CrossRefMap<Graph, Node, int> >();
   1.229 +    checkConcept<ReadWriteMap<Node, bool>,
   1.230 +                 CrossRefMap<Graph, Node, bool> >();
   1.231 +    checkConcept<ReadWriteMap<Node, double>,
   1.232 +                 CrossRefMap<Graph, Node, double> >();
   1.233 +    
   1.234 +    Graph gr;
   1.235 +    typedef CrossRefMap<Graph, Node, char> CRMap;
   1.236 +    CRMap map(gr);
   1.237 +    
   1.238 +    Node n0 = gr.addNode();
   1.239 +    Node n1 = gr.addNode();
   1.240 +    Node n2 = gr.addNode();
   1.241 +    
   1.242 +    map.set(n0, 'A');
   1.243 +    map.set(n1, 'B');
   1.244 +    map.set(n2, 'C');
   1.245 +    
   1.246 +    check(map[n0] == 'A' && map('A') == n0 && map.inverse()['A'] == n0,
   1.247 +          "Wrong CrossRefMap");
   1.248 +    check(map[n1] == 'B' && map('B') == n1 && map.inverse()['B'] == n1,
   1.249 +          "Wrong CrossRefMap");
   1.250 +    check(map[n2] == 'C' && map('C') == n2 && map.inverse()['C'] == n2,
   1.251 +          "Wrong CrossRefMap");
   1.252 +    check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1,
   1.253 +          "Wrong CrossRefMap::count()");
   1.254 +    
   1.255 +    CRMap::ValueIt it = map.beginValue();
   1.256 +    check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
   1.257 +          it == map.endValue(), "Wrong value iterator");
   1.258 +    
   1.259 +    map.set(n2, 'A');
   1.260 +
   1.261 +    check(map[n0] == 'A' && map[n1] == 'B' && map[n2] == 'A',
   1.262 +          "Wrong CrossRefMap");
   1.263 +    check(map('A') == n0 && map.inverse()['A'] == n0, "Wrong CrossRefMap");
   1.264 +    check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
   1.265 +    check(map('C') == INVALID && map.inverse()['C'] == INVALID,
   1.266 +          "Wrong CrossRefMap");
   1.267 +    check(map.count('A') == 2 && map.count('B') == 1 && map.count('C') == 0,
   1.268 +          "Wrong CrossRefMap::count()");
   1.269 +
   1.270 +    it = map.beginValue();
   1.271 +    check(*it++ == 'A' && *it++ == 'A' && *it++ == 'B' &&
   1.272 +          it == map.endValue(), "Wrong value iterator");
   1.273 +
   1.274 +    map.set(n0, 'C');
   1.275 +
   1.276 +    check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
   1.277 +          "Wrong CrossRefMap");
   1.278 +    check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
   1.279 +    check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
   1.280 +    check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
   1.281 +    check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1,
   1.282 +          "Wrong CrossRefMap::count()");
   1.283 +
   1.284 +    it = map.beginValue();
   1.285 +    check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
   1.286 +          it == map.endValue(), "Wrong value iterator");
   1.287    }
   1.288  
   1.289    // CrossRefMap
   1.290 @@ -546,10 +792,10 @@
   1.291        check(static_cast<Item>(it) == INVALID, "Wrong value");
   1.292      }
   1.293  
   1.294 -    for (Ivm::ValueIterator vit = map1.beginValue();
   1.295 +    for (Ivm::ValueIt vit = map1.beginValue();
   1.296           vit != map1.endValue(); ++vit) {
   1.297        check(map1[static_cast<Item>(Ivm::ItemIt(map1, *vit))] == *vit,
   1.298 -            "Wrong ValueIterator");
   1.299 +            "Wrong ValueIt");
   1.300      }
   1.301  
   1.302      for (int i = 0; i < num; ++i) {
   1.303 @@ -571,5 +817,183 @@
   1.304      check(n == num, "Wrong number");
   1.305  
   1.306    }
   1.307 +  
   1.308 +  // Graph map utilities:
   1.309 +  // mapMin(), mapMax(), mapMinValue(), mapMaxValue()
   1.310 +  // mapFind(), mapFindIf(), mapCount(), mapCountIf()
   1.311 +  // mapCopy(), mapCompare(), mapFill()
   1.312 +  {
   1.313 +    DIGRAPH_TYPEDEFS(SmartDigraph);
   1.314 +
   1.315 +    SmartDigraph g;
   1.316 +    Node n1 = g.addNode();
   1.317 +    Node n2 = g.addNode();
   1.318 +    Node n3 = g.addNode();
   1.319 +    
   1.320 +    SmartDigraph::NodeMap<int> map1(g);
   1.321 +    SmartDigraph::ArcMap<char> map2(g);
   1.322 +    ConstMap<Node, A> cmap1 = A();
   1.323 +    ConstMap<Arc, C> cmap2 = C(0);
   1.324 +    
   1.325 +    map1[n1] = 10;
   1.326 +    map1[n2] = 5;
   1.327 +    map1[n3] = 12;
   1.328 +    
   1.329 +    // mapMin(), mapMax(), mapMinValue(), mapMaxValue()
   1.330 +    check(mapMin(g, map1) == n2, "Wrong mapMin()");
   1.331 +    check(mapMax(g, map1) == n3, "Wrong mapMax()");
   1.332 +    check(mapMin(g, map1, std::greater<int>()) == n3, "Wrong mapMin()");
   1.333 +    check(mapMax(g, map1, std::greater<int>()) == n2, "Wrong mapMax()");
   1.334 +    check(mapMinValue(g, map1) == 5, "Wrong mapMinValue()");
   1.335 +    check(mapMaxValue(g, map1) == 12, "Wrong mapMaxValue()");
   1.336 +
   1.337 +    check(mapMin(g, map2) == INVALID, "Wrong mapMin()");
   1.338 +    check(mapMax(g, map2) == INVALID, "Wrong mapMax()");
   1.339 +
   1.340 +    check(mapMin(g, cmap1) != INVALID, "Wrong mapMin()");
   1.341 +    check(mapMax(g, cmap2) == INVALID, "Wrong mapMax()");
   1.342 +
   1.343 +    Arc a1 = g.addArc(n1, n2);
   1.344 +    Arc a2 = g.addArc(n1, n3);
   1.345 +    Arc a3 = g.addArc(n2, n3);
   1.346 +    Arc a4 = g.addArc(n3, n1);
   1.347 +    
   1.348 +    map2[a1] = 'b';
   1.349 +    map2[a2] = 'a';
   1.350 +    map2[a3] = 'b';
   1.351 +    map2[a4] = 'c';
   1.352 +
   1.353 +    // mapMin(), mapMax(), mapMinValue(), mapMaxValue()
   1.354 +    check(mapMin(g, map2) == a2, "Wrong mapMin()");
   1.355 +    check(mapMax(g, map2) == a4, "Wrong mapMax()");
   1.356 +    check(mapMin(g, map2, std::greater<int>()) == a4, "Wrong mapMin()");
   1.357 +    check(mapMax(g, map2, std::greater<int>()) == a2, "Wrong mapMax()");
   1.358 +    check(mapMinValue(g, map2, std::greater<int>()) == 'c',
   1.359 +          "Wrong mapMinValue()");
   1.360 +    check(mapMaxValue(g, map2, std::greater<int>()) == 'a',
   1.361 +          "Wrong mapMaxValue()");
   1.362 +
   1.363 +    check(mapMin(g, cmap1) != INVALID, "Wrong mapMin()");
   1.364 +    check(mapMax(g, cmap2) != INVALID, "Wrong mapMax()");
   1.365 +    check(mapMaxValue(g, cmap2) == C(0), "Wrong mapMaxValue()");
   1.366 +
   1.367 +    check(mapMin(g, composeMap(functorToMap(&createC), map2)) == a2,
   1.368 +          "Wrong mapMin()");
   1.369 +    check(mapMax(g, composeMap(functorToMap(&createC), map2)) == a4,
   1.370 +          "Wrong mapMax()");
   1.371 +    check(mapMinValue(g, composeMap(functorToMap(&createC), map2)) == C('a'),
   1.372 +          "Wrong mapMinValue()");
   1.373 +    check(mapMaxValue(g, composeMap(functorToMap(&createC), map2)) == C('c'),
   1.374 +          "Wrong mapMaxValue()");
   1.375 +
   1.376 +    // mapFind(), mapFindIf()
   1.377 +    check(mapFind(g, map1, 5) == n2, "Wrong mapFind()");
   1.378 +    check(mapFind(g, map1, 6) == INVALID, "Wrong mapFind()");
   1.379 +    check(mapFind(g, map2, 'a') == a2, "Wrong mapFind()");
   1.380 +    check(mapFind(g, map2, 'e') == INVALID, "Wrong mapFind()");
   1.381 +    check(mapFind(g, cmap2, C(0)) == ArcIt(g), "Wrong mapFind()");
   1.382 +    check(mapFind(g, cmap2, C(1)) == INVALID, "Wrong mapFind()");
   1.383 +
   1.384 +    check(mapFindIf(g, map1, Less<int>(7)) == n2,
   1.385 +          "Wrong mapFindIf()");
   1.386 +    check(mapFindIf(g, map1, Less<int>(5)) == INVALID,
   1.387 +          "Wrong mapFindIf()");
   1.388 +    check(mapFindIf(g, map2, Less<char>('d')) == ArcIt(g),
   1.389 +          "Wrong mapFindIf()");
   1.390 +    check(mapFindIf(g, map2, Less<char>('a')) == INVALID,
   1.391 +          "Wrong mapFindIf()");
   1.392 +
   1.393 +    // mapCount(), mapCountIf()
   1.394 +    check(mapCount(g, map1, 5) == 1, "Wrong mapCount()");
   1.395 +    check(mapCount(g, map1, 6) == 0, "Wrong mapCount()");
   1.396 +    check(mapCount(g, map2, 'a') == 1, "Wrong mapCount()");
   1.397 +    check(mapCount(g, map2, 'b') == 2, "Wrong mapCount()");
   1.398 +    check(mapCount(g, map2, 'e') == 0, "Wrong mapCount()");
   1.399 +    check(mapCount(g, cmap2, C(0)) == 4, "Wrong mapCount()");
   1.400 +    check(mapCount(g, cmap2, C(1)) == 0, "Wrong mapCount()");
   1.401 +
   1.402 +    check(mapCountIf(g, map1, Less<int>(11)) == 2,
   1.403 +          "Wrong mapCountIf()");
   1.404 +    check(mapCountIf(g, map1, Less<int>(13)) == 3,
   1.405 +          "Wrong mapCountIf()");
   1.406 +    check(mapCountIf(g, map1, Less<int>(5)) == 0,
   1.407 +          "Wrong mapCountIf()");
   1.408 +    check(mapCountIf(g, map2, Less<char>('d')) == 4,
   1.409 +          "Wrong mapCountIf()");
   1.410 +    check(mapCountIf(g, map2, Less<char>('c')) == 3,
   1.411 +          "Wrong mapCountIf()");
   1.412 +    check(mapCountIf(g, map2, Less<char>('a')) == 0,
   1.413 +          "Wrong mapCountIf()");
   1.414 +     
   1.415 +    // MapIt, ConstMapIt
   1.416 +/*
   1.417 +These tests can be used after applying bugfix #330
   1.418 +    typedef SmartDigraph::NodeMap<int>::MapIt MapIt;
   1.419 +    typedef SmartDigraph::NodeMap<int>::ConstMapIt ConstMapIt;
   1.420 +    check(*std::min_element(MapIt(map1), MapIt(INVALID)) == 5,
   1.421 +          "Wrong NodeMap<>::MapIt");
   1.422 +    check(*std::max_element(ConstMapIt(map1), ConstMapIt(INVALID)) == 12,
   1.423 +          "Wrong NodeMap<>::MapIt");
   1.424 +    
   1.425 +    int sum = 0;
   1.426 +    std::for_each(MapIt(map1), MapIt(INVALID), Sum<int>(sum));
   1.427 +    check(sum == 27, "Wrong NodeMap<>::MapIt");
   1.428 +    std::for_each(ConstMapIt(map1), ConstMapIt(INVALID), Sum<int>(sum));
   1.429 +    check(sum == 54, "Wrong NodeMap<>::ConstMapIt");
   1.430 +*/
   1.431 +
   1.432 +    // mapCopy(), mapCompare(), mapFill()
   1.433 +    check(mapCompare(g, map1, map1), "Wrong mapCompare()");
   1.434 +    check(mapCompare(g, cmap2, cmap2), "Wrong mapCompare()");
   1.435 +    check(mapCompare(g, map1, shiftMap(map1, 0)), "Wrong mapCompare()");
   1.436 +    check(mapCompare(g, map2, scaleMap(map2, 1)), "Wrong mapCompare()");
   1.437 +    check(!mapCompare(g, map1, shiftMap(map1, 1)), "Wrong mapCompare()");
   1.438 +
   1.439 +    SmartDigraph::NodeMap<int> map3(g, 0);
   1.440 +    SmartDigraph::ArcMap<char> map4(g, 'a');
   1.441 +    
   1.442 +    check(!mapCompare(g, map1, map3), "Wrong mapCompare()");
   1.443 +    check(!mapCompare(g, map2, map4), "Wrong mapCompare()");    
   1.444 +    
   1.445 +    mapCopy(g, map1, map3);
   1.446 +    mapCopy(g, map2, map4);
   1.447 +
   1.448 +    check(mapCompare(g, map1, map3), "Wrong mapCompare() or mapCopy()");
   1.449 +    check(mapCompare(g, map2, map4), "Wrong mapCompare() or mapCopy()");    
   1.450 +    
   1.451 +    Undirector<SmartDigraph> ug(g);
   1.452 +    Undirector<SmartDigraph>::EdgeMap<char> umap1(ug, 'x');
   1.453 +    Undirector<SmartDigraph>::ArcMap<double> umap2(ug, 3.14);
   1.454 +    
   1.455 +    check(!mapCompare(g, map2, umap1), "Wrong mapCompare() or mapCopy()");
   1.456 +    check(!mapCompare(g, umap1, map2), "Wrong mapCompare() or mapCopy()");
   1.457 +    check(!mapCompare(ug, map2, umap1), "Wrong mapCompare() or mapCopy()");
   1.458 +    check(!mapCompare(ug, umap1, map2), "Wrong mapCompare() or mapCopy()");
   1.459 +    
   1.460 +    mapCopy(g, map2, umap1);
   1.461 +
   1.462 +    check(mapCompare(g, map2, umap1), "Wrong mapCompare() or mapCopy()");
   1.463 +    check(mapCompare(g, umap1, map2), "Wrong mapCompare() or mapCopy()");
   1.464 +    check(mapCompare(ug, map2, umap1), "Wrong mapCompare() or mapCopy()");
   1.465 +    check(mapCompare(ug, umap1, map2), "Wrong mapCompare() or mapCopy()");
   1.466 +    
   1.467 +    mapCopy(g, map2, umap1);
   1.468 +    mapCopy(g, umap1, map2);
   1.469 +    mapCopy(ug, map2, umap1);
   1.470 +    mapCopy(ug, umap1, map2);
   1.471 +    
   1.472 +    check(!mapCompare(ug, umap1, umap2), "Wrong mapCompare() or mapCopy()");
   1.473 +    mapCopy(ug, umap1, umap2);
   1.474 +    check(mapCompare(ug, umap1, umap2), "Wrong mapCompare() or mapCopy()");
   1.475 +    
   1.476 +    check(!mapCompare(g, map1, constMap<Node>(2)), "Wrong mapCompare()");
   1.477 +    mapFill(g, map1, 2);
   1.478 +    check(mapCompare(g, constMap<Node>(2), map1), "Wrong mapFill()");
   1.479 +
   1.480 +    check(!mapCompare(g, map2, constMap<Arc>('z')), "Wrong mapCompare()");
   1.481 +    mapCopy(g, constMap<Arc>('z'), map2);
   1.482 +    check(mapCompare(g, constMap<Arc>('z'), map2), "Wrong mapCopy()");
   1.483 +  }
   1.484 +  
   1.485    return 0;
   1.486  }