alpar@1956
|
1 |
/* -*- C++ -*-
|
alpar@1956
|
2 |
*
|
alpar@1956
|
3 |
* This file is a part of LEMON, a generic C++ optimization library
|
alpar@1956
|
4 |
*
|
alpar@1956
|
5 |
* Copyright (C) 2003-2006
|
alpar@1956
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@1956
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
alpar@1956
|
8 |
*
|
alpar@1956
|
9 |
* Permission to use, modify and distribute this software is granted
|
alpar@1956
|
10 |
* provided that this copyright notice appears in all copies. For
|
alpar@1956
|
11 |
* precise terms see the accompanying LICENSE file.
|
alpar@1956
|
12 |
*
|
alpar@1956
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
alpar@1956
|
14 |
* express or implied, and with no claim as to its suitability for any
|
alpar@1956
|
15 |
* purpose.
|
alpar@1956
|
16 |
*
|
alpar@1956
|
17 |
*/
|
alpar@1956
|
18 |
|
deba@2032
|
19 |
#include <deque>
|
deba@2032
|
20 |
#include <set>
|
deba@2032
|
21 |
|
alpar@1041
|
22 |
#include <lemon/concept_check.h>
|
alpar@2260
|
23 |
#include <lemon/concepts/maps.h>
|
alpar@1041
|
24 |
#include <lemon/maps.h>
|
alpar@1041
|
25 |
|
alpar@1041
|
26 |
#include "test_tools.h"
|
alpar@1041
|
27 |
|
alpar@1041
|
28 |
using namespace lemon;
|
alpar@2260
|
29 |
using namespace lemon::concepts;
|
alpar@1041
|
30 |
|
alpar@1041
|
31 |
struct A {};
|
deba@2032
|
32 |
inline bool operator<(A, A) { return true; }
|
alpar@1041
|
33 |
struct B {};
|
deba@1675
|
34 |
|
deba@1675
|
35 |
class F {
|
alpar@1076
|
36 |
public:
|
deba@1675
|
37 |
typedef A argument_type;
|
deba@1675
|
38 |
typedef B result_type;
|
deba@1675
|
39 |
|
alpar@1375
|
40 |
B operator()(const A &) const {return B();}
|
alpar@1076
|
41 |
};
|
alpar@1076
|
42 |
|
alpar@1375
|
43 |
int func(A) {return 3;}
|
alpar@1041
|
44 |
|
deba@1675
|
45 |
int binc(int, B) {return 4;}
|
deba@1675
|
46 |
|
alpar@1041
|
47 |
typedef ReadMap<A,double> DoubleMap;
|
deba@2032
|
48 |
typedef ReadWriteMap<A, double> WriteDoubleMap;
|
deba@2032
|
49 |
|
deba@2032
|
50 |
typedef ReadMap<A,bool> BoolMap;
|
deba@2032
|
51 |
typedef ReadWriteMap<A, bool> BoolWriteMap;
|
alpar@1041
|
52 |
|
alpar@1041
|
53 |
int main()
|
alpar@1041
|
54 |
{ // checking graph components
|
alpar@1041
|
55 |
|
alpar@1041
|
56 |
checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
|
alpar@1041
|
57 |
checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
|
alpar@1041
|
58 |
checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
|
alpar@1041
|
59 |
checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
|
alpar@1041
|
60 |
|
alpar@1041
|
61 |
checkConcept<ReadMap<A,double>, AddMap<DoubleMap,DoubleMap> >();
|
alpar@1041
|
62 |
checkConcept<ReadMap<A,double>, SubMap<DoubleMap,DoubleMap> >();
|
alpar@1041
|
63 |
checkConcept<ReadMap<A,double>, MulMap<DoubleMap,DoubleMap> >();
|
alpar@1041
|
64 |
checkConcept<ReadMap<A,double>, DivMap<DoubleMap,DoubleMap> >();
|
alpar@1041
|
65 |
checkConcept<ReadMap<A,double>, NegMap<DoubleMap> >();
|
deba@2032
|
66 |
checkConcept<ReadWriteMap<A,double>, NegWriteMap<WriteDoubleMap> >();
|
alpar@1041
|
67 |
checkConcept<ReadMap<A,double>, AbsMap<DoubleMap> >();
|
alpar@1070
|
68 |
checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
|
deba@2032
|
69 |
checkConcept<ReadWriteMap<A,double>, ShiftWriteMap<WriteDoubleMap> >();
|
alpar@1070
|
70 |
checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
|
deba@2032
|
71 |
checkConcept<ReadWriteMap<A,double>, ScaleWriteMap<WriteDoubleMap> >();
|
deba@2032
|
72 |
checkConcept<ReadMap<A,double>, ForkMap<DoubleMap, DoubleMap> >();
|
deba@2032
|
73 |
checkConcept<ReadWriteMap<A,double>,
|
deba@2032
|
74 |
ForkWriteMap<WriteDoubleMap, WriteDoubleMap> >();
|
alpar@1041
|
75 |
|
alpar@1041
|
76 |
checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
|
alpar@1041
|
77 |
|
deba@1675
|
78 |
checkConcept<ReadMap<A,B>, FunctorMap<F, A, B> >();
|
alpar@1076
|
79 |
|
deba@2032
|
80 |
checkConcept<ReadMap<A, bool>, NotMap<BoolMap> >();
|
deba@2032
|
81 |
checkConcept<ReadWriteMap<A, bool>, NotWriteMap<BoolWriteMap> >();
|
deba@2032
|
82 |
|
deba@2032
|
83 |
checkConcept<WriteMap<A, bool>, StoreBoolMap<A*> >();
|
deba@2032
|
84 |
checkConcept<WriteMap<A, bool>, BackInserterBoolMap<std::deque<A> > >();
|
deba@2032
|
85 |
checkConcept<WriteMap<A, bool>, FrontInserterBoolMap<std::deque<A> > >();
|
deba@2032
|
86 |
checkConcept<WriteMap<A, bool>, InserterBoolMap<std::set<A> > >();
|
deba@2032
|
87 |
checkConcept<WriteMap<A, bool>, FillBoolMap<WriteMap<A, B> > >();
|
deba@2032
|
88 |
checkConcept<WriteMap<A, bool>, SettingOrderBoolMap<WriteMap<A, int> > >();
|
deba@2032
|
89 |
|
alpar@1076
|
90 |
int a;
|
alpar@1076
|
91 |
|
alpar@1076
|
92 |
a=mapFunctor(constMap<A,int>(2))(A());
|
alpar@1076
|
93 |
check(a==2,"Something is wrong with mapFunctor");
|
alpar@1076
|
94 |
|
alpar@1076
|
95 |
B b;
|
deba@1675
|
96 |
b=functorMap(F())[A()];
|
alpar@1076
|
97 |
|
deba@1675
|
98 |
a=functorMap(&func)[A()];
|
alpar@1076
|
99 |
check(a==3,"Something is wrong with functorMap");
|
alpar@1076
|
100 |
|
deba@1675
|
101 |
a=combineMap(constMap<B, int, 1>(), identityMap<B>(), &binc)[B()];
|
deba@1675
|
102 |
check(a==4,"Something is wrong with combineMap");
|
deba@1675
|
103 |
|
deba@1675
|
104 |
|
alpar@1041
|
105 |
std::cout << __FILE__ ": All tests passed.\n";
|
alpar@1041
|
106 |
|
alpar@1041
|
107 |
return 0;
|
alpar@1041
|
108 |
}
|