1 | #include <lemon/concept_check.h> |
---|
2 | #include <lemon/concept/maps.h> |
---|
3 | #include <lemon/maps.h> |
---|
4 | |
---|
5 | #include "test_tools.h" |
---|
6 | |
---|
7 | using namespace lemon; |
---|
8 | using namespace lemon::concept; |
---|
9 | |
---|
10 | struct A {}; |
---|
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;} |
---|
19 | |
---|
20 | typedef ReadMap<A,double> DoubleMap; |
---|
21 | |
---|
22 | int 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 | } |
---|