test/maps_test.cc
changeset 2152 ba87d27667cd
parent 1956 a055123339d5
child 2260 4274224f8a7d
equal deleted inserted replaced
2:4e312ef7dfb1 3:71ea1bdd6671
    14  * express or implied, and with no claim as to its suitability for any
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    15  * purpose.
    16  *
    16  *
    17  */
    17  */
    18 
    18 
       
    19 #include <deque>
       
    20 #include <set>
       
    21 
    19 #include <lemon/concept_check.h>
    22 #include <lemon/concept_check.h>
    20 #include <lemon/concept/maps.h>
    23 #include <lemon/concept/maps.h>
    21 #include <lemon/maps.h>
    24 #include <lemon/maps.h>
    22 
    25 
    23 #include "test_tools.h"
    26 #include "test_tools.h"
    24 
    27 
    25 using namespace lemon;
    28 using namespace lemon;
    26 using namespace lemon::concept;
    29 using namespace lemon::concept;
    27 
    30 
    28 struct A {};
    31 struct A {};
       
    32 inline bool operator<(A, A) { return true; }
    29 struct B {};
    33 struct B {};
    30 
    34 
    31 class F {
    35 class F {
    32 public:
    36 public:
    33   typedef A argument_type;
    37   typedef A argument_type;
    39 int func(A) {return 3;}
    43 int func(A) {return 3;}
    40 
    44 
    41 int binc(int, B) {return 4;}
    45 int binc(int, B) {return 4;}
    42 
    46 
    43 typedef ReadMap<A,double> DoubleMap;
    47 typedef ReadMap<A,double> DoubleMap;
       
    48 typedef ReadWriteMap<A, double> WriteDoubleMap;
       
    49 
       
    50 typedef ReadMap<A,bool> BoolMap;
       
    51 typedef ReadWriteMap<A, bool> BoolWriteMap;
    44 
    52 
    45 int main()
    53 int main()
    46 { // checking graph components
    54 { // checking graph components
    47   
    55   
    48   checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
    56   checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
    53   checkConcept<ReadMap<A,double>, AddMap<DoubleMap,DoubleMap> >();
    61   checkConcept<ReadMap<A,double>, AddMap<DoubleMap,DoubleMap> >();
    54   checkConcept<ReadMap<A,double>, SubMap<DoubleMap,DoubleMap> >();
    62   checkConcept<ReadMap<A,double>, SubMap<DoubleMap,DoubleMap> >();
    55   checkConcept<ReadMap<A,double>, MulMap<DoubleMap,DoubleMap> >();
    63   checkConcept<ReadMap<A,double>, MulMap<DoubleMap,DoubleMap> >();
    56   checkConcept<ReadMap<A,double>, DivMap<DoubleMap,DoubleMap> >();
    64   checkConcept<ReadMap<A,double>, DivMap<DoubleMap,DoubleMap> >();
    57   checkConcept<ReadMap<A,double>, NegMap<DoubleMap> >();
    65   checkConcept<ReadMap<A,double>, NegMap<DoubleMap> >();
       
    66   checkConcept<ReadWriteMap<A,double>, NegWriteMap<WriteDoubleMap> >();
    58   checkConcept<ReadMap<A,double>, AbsMap<DoubleMap> >();
    67   checkConcept<ReadMap<A,double>, AbsMap<DoubleMap> >();
    59   checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
    68   checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
       
    69   checkConcept<ReadWriteMap<A,double>, ShiftWriteMap<WriteDoubleMap> >();
    60   checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
    70   checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
       
    71   checkConcept<ReadWriteMap<A,double>, ScaleWriteMap<WriteDoubleMap> >();
       
    72   checkConcept<ReadMap<A,double>, ForkMap<DoubleMap, DoubleMap> >();
       
    73   checkConcept<ReadWriteMap<A,double>, 
       
    74     ForkWriteMap<WriteDoubleMap, WriteDoubleMap> >();
    61   
    75   
    62   checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
    76   checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
    63 
    77 
    64   checkConcept<ReadMap<A,B>, FunctorMap<F, A, B> >();
    78   checkConcept<ReadMap<A,B>, FunctorMap<F, A, B> >();
       
    79 
       
    80   checkConcept<ReadMap<A, bool>, NotMap<BoolMap> >();
       
    81   checkConcept<ReadWriteMap<A, bool>, NotWriteMap<BoolWriteMap> >();
       
    82 
       
    83   checkConcept<WriteMap<A, bool>, StoreBoolMap<A*> >();
       
    84   checkConcept<WriteMap<A, bool>, BackInserterBoolMap<std::deque<A> > >();
       
    85   checkConcept<WriteMap<A, bool>, FrontInserterBoolMap<std::deque<A> > >();
       
    86   checkConcept<WriteMap<A, bool>, InserterBoolMap<std::set<A> > >();
       
    87   checkConcept<WriteMap<A, bool>, FillBoolMap<WriteMap<A, B> > >();
       
    88   checkConcept<WriteMap<A, bool>, SettingOrderBoolMap<WriteMap<A, int> > >();
    65 
    89 
    66   int a;
    90   int a;
    67   
    91   
    68   a=mapFunctor(constMap<A,int>(2))(A());
    92   a=mapFunctor(constMap<A,int>(2))(A());
    69   check(a==2,"Something is wrong with mapFunctor");
    93   check(a==2,"Something is wrong with mapFunctor");