alpar@1041
|
1 |
#include <lemon/concept_check.h>
|
alpar@1041
|
2 |
#include <lemon/concept/maps.h>
|
alpar@1041
|
3 |
#include <lemon/maps.h>
|
alpar@1041
|
4 |
|
alpar@1041
|
5 |
#include "test_tools.h"
|
alpar@1041
|
6 |
|
alpar@1041
|
7 |
using namespace lemon;
|
alpar@1041
|
8 |
using namespace lemon::concept;
|
alpar@1041
|
9 |
|
alpar@1041
|
10 |
struct A {};
|
alpar@1041
|
11 |
struct B {};
|
alpar@1076
|
12 |
class F
|
alpar@1076
|
13 |
{
|
alpar@1076
|
14 |
public:
|
alpar@1076
|
15 |
B operator()(const A &a) const {return B();}
|
alpar@1076
|
16 |
};
|
alpar@1076
|
17 |
|
alpar@1076
|
18 |
int func(A a) {return 3;}
|
alpar@1041
|
19 |
|
alpar@1041
|
20 |
typedef ReadMap<A,double> DoubleMap;
|
alpar@1041
|
21 |
|
alpar@1041
|
22 |
int main()
|
alpar@1041
|
23 |
{ // checking graph components
|
alpar@1041
|
24 |
|
alpar@1041
|
25 |
checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
|
alpar@1041
|
26 |
checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
|
alpar@1041
|
27 |
checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
|
alpar@1041
|
28 |
checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
|
alpar@1041
|
29 |
|
alpar@1041
|
30 |
checkConcept<ReadMap<A,double>, AddMap<DoubleMap,DoubleMap> >();
|
alpar@1041
|
31 |
checkConcept<ReadMap<A,double>, SubMap<DoubleMap,DoubleMap> >();
|
alpar@1041
|
32 |
checkConcept<ReadMap<A,double>, MulMap<DoubleMap,DoubleMap> >();
|
alpar@1041
|
33 |
checkConcept<ReadMap<A,double>, DivMap<DoubleMap,DoubleMap> >();
|
alpar@1041
|
34 |
checkConcept<ReadMap<A,double>, NegMap<DoubleMap> >();
|
alpar@1041
|
35 |
checkConcept<ReadMap<A,double>, AbsMap<DoubleMap> >();
|
alpar@1070
|
36 |
checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
|
alpar@1070
|
37 |
checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
|
alpar@1041
|
38 |
|
alpar@1041
|
39 |
checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
|
alpar@1041
|
40 |
|
alpar@1076
|
41 |
checkConcept<ReadMap<A,B>, FunctorMap<A,B,F> >();
|
alpar@1076
|
42 |
|
alpar@1076
|
43 |
int a;
|
alpar@1076
|
44 |
|
alpar@1076
|
45 |
a=mapFunctor(constMap<A,int>(2))(A());
|
alpar@1076
|
46 |
check(a==2,"Something is wrong with mapFunctor");
|
alpar@1076
|
47 |
|
alpar@1076
|
48 |
B b;
|
alpar@1076
|
49 |
b=functorMap<A,B>(F())[A()];
|
alpar@1076
|
50 |
|
alpar@1076
|
51 |
a=functorMap<A,int>(&func)[A()];
|
alpar@1076
|
52 |
check(a==3,"Something is wrong with functorMap");
|
alpar@1076
|
53 |
|
alpar@1041
|
54 |
std::cout << __FILE__ ": All tests passed.\n";
|
alpar@1041
|
55 |
|
alpar@1041
|
56 |
return 0;
|
alpar@1041
|
57 |
}
|