test/maps_test.cc
branch1.1
changeset 788 98b306776b25
parent 684 7b1a6e963018
child 793 8d2e55fac752
equal deleted inserted replaced
13:4a6b01c1896b 14:797d77020d63
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2009
     5  * Copyright (C) 2003-2011
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
    68   checkConcept<ReadMap<A,C>, ReadMap<A,C> >();
    68   checkConcept<ReadMap<A,C>, ReadMap<A,C> >();
    69   checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
    69   checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
    70   checkConcept<WriteMap<A,C>, WriteMap<A,C> >();
    70   checkConcept<WriteMap<A,C>, WriteMap<A,C> >();
    71   checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
    71   checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
    72   checkConcept<ReadWriteMap<A,C>, ReadWriteMap<A,C> >();
    72   checkConcept<ReadWriteMap<A,C>, ReadWriteMap<A,C> >();
    73   checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
    73   checkConcept<ReferenceMap<A,B,B&,const B&>,
    74   checkConcept<ReferenceMap<A,C,C&,const C&>, ReferenceMap<A,C,C&,const C&> >();
    74                ReferenceMap<A,B,B&,const B&> >();
       
    75   checkConcept<ReferenceMap<A,C,C&,const C&>,
       
    76                ReferenceMap<A,C,C&,const C&> >();
    75 
    77 
    76   // NullMap
    78   // NullMap
    77   {
    79   {
    78     checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >();
    80     checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >();
    79     NullMap<A,B> map1;
    81     NullMap<A,B> map1;
   198     FunctorToMap<F> map1;
   200     FunctorToMap<F> map1;
   199     FunctorToMap<F> map2 = FunctorToMap<F>(F());
   201     FunctorToMap<F> map2 = FunctorToMap<F>(F());
   200     B b = functorToMap(F())[A()];
   202     B b = functorToMap(F())[A()];
   201 
   203 
   202     checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
   204     checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
   203     MapToFunctor<ReadMap<A,B> > map = MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
   205     MapToFunctor<ReadMap<A,B> > map =
       
   206       MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
   204 
   207 
   205     check(functorToMap(&func)[A()] == 3,
   208     check(functorToMap(&func)[A()] == 3,
   206           "Something is wrong with FunctorToMap");
   209           "Something is wrong with FunctorToMap");
   207     check(mapToFunctor(constMap<A,int>(2))(A()) == 2,
   210     check(mapToFunctor(constMap<A,int>(2))(A()) == 2,
   208           "Something is wrong with MapToFunctor");
   211           "Something is wrong with MapToFunctor");
   347     int i = 0;
   350     int i = 0;
   348     for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
   351     for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
   349           it != map2.end(); ++it )
   352           it != map2.end(); ++it )
   350       check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
   353       check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
   351   }
   354   }
   352   
   355 
   353   // CrossRefMap
   356   // CrossRefMap
   354   {
   357   {
   355     typedef ListDigraph Graph;
   358     typedef ListDigraph Graph;
   356     DIGRAPH_TYPEDEFS(Graph);
   359     DIGRAPH_TYPEDEFS(Graph);
   357 
   360 
   358     checkConcept<ReadWriteMap<Node, int>,
   361     checkConcept<ReadWriteMap<Node, int>,
   359                  CrossRefMap<Graph, Node, int> >();
   362                  CrossRefMap<Graph, Node, int> >();
   360     
   363 
   361     Graph gr;
   364     Graph gr;
   362     typedef CrossRefMap<Graph, Node, char> CRMap;
   365     typedef CrossRefMap<Graph, Node, char> CRMap;
   363     typedef CRMap::ValueIterator ValueIt;
   366     typedef CRMap::ValueIterator ValueIt;
   364     CRMap map(gr);
   367     CRMap map(gr);
   365     
   368 
   366     Node n0 = gr.addNode();
   369     Node n0 = gr.addNode();
   367     Node n1 = gr.addNode();
   370     Node n1 = gr.addNode();
   368     Node n2 = gr.addNode();
   371     Node n2 = gr.addNode();
   369     
   372 
   370     map.set(n0, 'A');
   373     map.set(n0, 'A');
   371     map.set(n1, 'B');
   374     map.set(n1, 'B');
   372     map.set(n2, 'C');
   375     map.set(n2, 'C');
   373     map.set(n2, 'A');
   376     map.set(n2, 'A');
   374     map.set(n0, 'C');
   377     map.set(n0, 'C');