test/maps_test.cc
branch1.1
changeset 714 c6f725eff737
parent 477 e6ae4999cf22
child 761 f1398882a928
child 792 761fe0846f49
equal deleted inserted replaced
12:7c1e8eb00d0c 13:4a6b01c1896b
    20 #include <set>
    20 #include <set>
    21 
    21 
    22 #include <lemon/concept_check.h>
    22 #include <lemon/concept_check.h>
    23 #include <lemon/concepts/maps.h>
    23 #include <lemon/concepts/maps.h>
    24 #include <lemon/maps.h>
    24 #include <lemon/maps.h>
       
    25 #include <lemon/list_graph.h>
    25 
    26 
    26 #include "test_tools.h"
    27 #include "test_tools.h"
    27 
    28 
    28 using namespace lemon;
    29 using namespace lemon;
    29 using namespace lemon::concepts;
    30 using namespace lemon::concepts;
   346     int i = 0;
   347     int i = 0;
   347     for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
   348     for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
   348           it != map2.end(); ++it )
   349           it != map2.end(); ++it )
   349       check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
   350       check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
   350   }
   351   }
       
   352   
       
   353   // CrossRefMap
       
   354   {
       
   355     typedef ListDigraph Graph;
       
   356     DIGRAPH_TYPEDEFS(Graph);
       
   357 
       
   358     checkConcept<ReadWriteMap<Node, int>,
       
   359                  CrossRefMap<Graph, Node, int> >();
       
   360     
       
   361     Graph gr;
       
   362     typedef CrossRefMap<Graph, Node, char> CRMap;
       
   363     typedef CRMap::ValueIterator ValueIt;
       
   364     CRMap map(gr);
       
   365     
       
   366     Node n0 = gr.addNode();
       
   367     Node n1 = gr.addNode();
       
   368     Node n2 = gr.addNode();
       
   369     
       
   370     map.set(n0, 'A');
       
   371     map.set(n1, 'B');
       
   372     map.set(n2, 'C');
       
   373     map.set(n2, 'A');
       
   374     map.set(n0, 'C');
       
   375 
       
   376     check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
       
   377           "Wrong CrossRefMap");
       
   378     check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
       
   379     check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
       
   380     check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
       
   381 
       
   382     ValueIt it = map.beginValue();
       
   383     check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
       
   384           it == map.endValue(), "Wrong value iterator");
       
   385   }
   351 
   386 
   352   return 0;
   387   return 0;
   353 }
   388 }