src/test/maps_test.cc
changeset 1266 74d616d081f0
parent 1070 6aa1520a0f2f
child 1375 ebdce4f68ac4
equal deleted inserted replaced
1:eb24cf2dac2d 2:3c1d0c7259a7
     7 using namespace lemon;
     7 using namespace lemon;
     8 using namespace lemon::concept;
     8 using namespace lemon::concept;
     9 
     9 
    10 struct A {};
    10 struct A {};
    11 struct B {};
    11 struct B {};
       
    12 class F
       
    13 {
       
    14 public:
       
    15   B operator()(const A &a) const {return B();}
       
    16 };
       
    17 
       
    18 int func(A a) {return 3;}
    12 
    19 
    13 typedef ReadMap<A,double> DoubleMap;
    20 typedef ReadMap<A,double> DoubleMap;
    14 
    21 
    15 int main()
    22 int main()
    16 { // checking graph components
    23 { // checking graph components
    29   checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
    36   checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
    30   checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
    37   checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
    31   
    38   
    32   checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
    39   checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
    33 
    40 
       
    41   checkConcept<ReadMap<A,B>, FunctorMap<A,B,F> >();
       
    42 
       
    43   int a;
       
    44   
       
    45   a=mapFunctor(constMap<A,int>(2))(A());
       
    46   check(a==2,"Something is wrong with mapFunctor");
       
    47 
       
    48   B b;
       
    49   b=functorMap<A,B>(F())[A()];
       
    50 
       
    51   a=functorMap<A,int>(&func)[A()];
       
    52   check(a==3,"Something is wrong with functorMap");
       
    53 
    34   std::cout << __FILE__ ": All tests passed.\n";
    54   std::cout << __FILE__ ": All tests passed.\n";
    35   
    55   
    36   return 0;
    56   return 0;
    37 }
    57 }