COIN-OR::LEMON - Graph Library

source: lemon-0.x/test/maps_test.cc @ 1482:b9818eea0550

Last change on this file since 1482:b9818eea0550 was 1435:8e85e6bbefdf, checked in by Akos Ladanyi, 20 years ago

trunk/src/* move to trunk/

File size: 1.5 KB
Line 
1#include <lemon/concept_check.h>
2#include <lemon/concept/maps.h>
3#include <lemon/maps.h>
4
5#include "test_tools.h"
6
7using namespace lemon;
8using namespace lemon::concept;
9
10struct A {};
11struct B {};
12class F
13{
14public:
15  B operator()(const A &) const {return B();}
16};
17
18int func(A) {return 3;}
19
20typedef ReadMap<A,double> DoubleMap;
21
22int main()
23{ // checking graph components
24 
25  checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
26  checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
27  checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
28  checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
29
30  checkConcept<ReadMap<A,double>, AddMap<DoubleMap,DoubleMap> >();
31  checkConcept<ReadMap<A,double>, SubMap<DoubleMap,DoubleMap> >();
32  checkConcept<ReadMap<A,double>, MulMap<DoubleMap,DoubleMap> >();
33  checkConcept<ReadMap<A,double>, DivMap<DoubleMap,DoubleMap> >();
34  checkConcept<ReadMap<A,double>, NegMap<DoubleMap> >();
35  checkConcept<ReadMap<A,double>, AbsMap<DoubleMap> >();
36  checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
37  checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
38 
39  checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
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
54  std::cout << __FILE__ ": All tests passed.\n";
55 
56  return 0;
57}
Note: See TracBrowser for help on using the repository browser.