COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/maps_test.cc @ 1387:37d1b20cd9ef

Last change on this file since 1387:37d1b20cd9ef was 1375:ebdce4f68ac4, checked in by Alpar Juttner, 19 years ago

Get rid of all '-Wall -W' warnings.

File size: 1.5 KB
RevLine 
[1041]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 {};
[1076]12class F
13{
14public:
[1375]15  B operator()(const A &) const {return B();}
[1076]16};
17
[1375]18int func(A) {return 3;}
[1041]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> >();
[1070]36  checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
37  checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
[1041]38 
39  checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
40
[1076]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
[1041]54  std::cout << __FILE__ ": All tests passed.\n";
55 
56  return 0;
57}
Note: See TracBrowser for help on using the repository browser.