test/maps_test.cc
changeset 774 4efe7b32b134
parent 477 e6ae4999cf22
child 761 f1398882a928
child 792 761fe0846f49
     1.1 --- a/test/maps_test.cc	Tue Dec 20 17:38:19 2011 +0100
     1.2 +++ b/test/maps_test.cc	Tue Dec 20 17:43:11 2011 +0100
     1.3 @@ -22,6 +22,7 @@
     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  
     1.9  #include "test_tools.h"
    1.10  
    1.11 @@ -348,6 +349,40 @@
    1.12            it != map2.end(); ++it )
    1.13        check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
    1.14    }
    1.15 +  
    1.16 +  // CrossRefMap
    1.17 +  {
    1.18 +    typedef ListDigraph Graph;
    1.19 +    DIGRAPH_TYPEDEFS(Graph);
    1.20 +
    1.21 +    checkConcept<ReadWriteMap<Node, int>,
    1.22 +                 CrossRefMap<Graph, Node, int> >();
    1.23 +    
    1.24 +    Graph gr;
    1.25 +    typedef CrossRefMap<Graph, Node, char> CRMap;
    1.26 +    typedef CRMap::ValueIterator ValueIt;
    1.27 +    CRMap map(gr);
    1.28 +    
    1.29 +    Node n0 = gr.addNode();
    1.30 +    Node n1 = gr.addNode();
    1.31 +    Node n2 = gr.addNode();
    1.32 +    
    1.33 +    map.set(n0, 'A');
    1.34 +    map.set(n1, 'B');
    1.35 +    map.set(n2, 'C');
    1.36 +    map.set(n2, 'A');
    1.37 +    map.set(n0, 'C');
    1.38 +
    1.39 +    check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
    1.40 +          "Wrong CrossRefMap");
    1.41 +    check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
    1.42 +    check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
    1.43 +    check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
    1.44 +
    1.45 +    ValueIt it = map.beginValue();
    1.46 +    check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
    1.47 +          it == map.endValue(), "Wrong value iterator");
    1.48 +  }
    1.49  
    1.50    return 0;
    1.51  }