diff --git a/test/maps_test.cc b/test/maps_test.cc new file mode 100644 --- /dev/null +++ b/test/maps_test.cc @@ -0,0 +1,108 @@ +/* -*- C++ -*- + * + * This file is a part of LEMON, a generic C++ optimization library + * + * Copyright (C) 2003-2007 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +#include +#include + +#include +#include +#include + +#include "test_tools.h" + +using namespace lemon; +using namespace lemon::concepts; + +struct A {}; +inline bool operator<(A, A) { return true; } +struct B {}; + +class F { +public: + typedef A argument_type; + typedef B result_type; + + B operator()(const A &) const {return B();} +}; + +int func(A) {return 3;} + +int binc(int, B) {return 4;} + +typedef ReadMap DoubleMap; +typedef ReadWriteMap WriteDoubleMap; + +typedef ReadMap BoolMap; +typedef ReadWriteMap BoolWriteMap; + +int main() +{ // checking graph components + + checkConcept, ReadMap >(); + checkConcept, WriteMap >(); + checkConcept, ReadWriteMap >(); + checkConcept, ReferenceMap >(); + + checkConcept, AddMap >(); + checkConcept, SubMap >(); + checkConcept, MulMap >(); + checkConcept, DivMap >(); + checkConcept, NegMap >(); + checkConcept, NegWriteMap >(); + checkConcept, AbsMap >(); + checkConcept, ShiftMap >(); + checkConcept, ShiftWriteMap >(); + checkConcept, ScaleMap >(); + checkConcept, ScaleWriteMap >(); + checkConcept, ForkMap >(); + checkConcept, + ForkWriteMap >(); + + checkConcept, ComposeMap > >(); + + checkConcept, FunctorMap >(); + + checkConcept, NotMap >(); + checkConcept, NotWriteMap >(); + + checkConcept, StoreBoolMap >(); + checkConcept, BackInserterBoolMap > >(); + checkConcept, FrontInserterBoolMap > >(); + checkConcept, InserterBoolMap > >(); + checkConcept, FillBoolMap > >(); + checkConcept, SettingOrderBoolMap > >(); + + int a; + + a=mapFunctor(constMap(2))(A()); + check(a==2,"Something is wrong with mapFunctor"); + + B b; + b=functorMap(F())[A()]; + + a=functorMap(&func)[A()]; + check(a==3,"Something is wrong with functorMap"); + + a=combineMap(constMap(), identityMap(), &binc)[B()]; + check(a==4,"Something is wrong with combineMap"); + + + std::cout << __FILE__ ": All tests passed.\n"; + + return 0; +}