test/maps_test.cc
branch1.0
changeset 505 b4c892aa217c
parent 210 81cfc04531e8
child 1078 c59bdcc8e33e
equal deleted inserted replaced
10:88bcd79d9210 12:cba29e78eff4
   168 
   168 
   169   // ComposeMap
   169   // ComposeMap
   170   {
   170   {
   171     typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
   171     typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
   172     checkConcept<ReadMap<B,double>, CompMap>();
   172     checkConcept<ReadMap<B,double>, CompMap>();
   173     CompMap map1(DoubleMap(),ReadMap<B,A>());
   173     CompMap map1 = CompMap(DoubleMap(),ReadMap<B,A>());
   174     CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
   174     CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
   175 
   175 
   176     SparseMap<double, bool> m1(false); m1[3.14] = true;
   176     SparseMap<double, bool> m1(false); m1[3.14] = true;
   177     RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
   177     RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
   178     check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1],
   178     check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1],
   181 
   181 
   182   // CombineMap
   182   // CombineMap
   183   {
   183   {
   184     typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
   184     typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
   185     checkConcept<ReadMap<A,double>, CombMap>();
   185     checkConcept<ReadMap<A,double>, CombMap>();
   186     CombMap map1(DoubleMap(), DoubleMap());
   186     CombMap map1 = CombMap(DoubleMap(), DoubleMap());
   187     CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
   187     CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
   188 
   188 
   189     check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3,
   189     check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3,
   190           "Something is wrong with CombineMap");
   190           "Something is wrong with CombineMap");
   191   }
   191   }
   193   // FunctorToMap, MapToFunctor
   193   // FunctorToMap, MapToFunctor
   194   {
   194   {
   195     checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >();
   195     checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >();
   196     checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
   196     checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
   197     FunctorToMap<F> map1;
   197     FunctorToMap<F> map1;
   198     FunctorToMap<F> map2(F());
   198     FunctorToMap<F> map2 = FunctorToMap<F>(F());
   199     B b = functorToMap(F())[A()];
   199     B b = functorToMap(F())[A()];
   200 
   200 
   201     checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
   201     checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
   202     MapToFunctor<ReadMap<A,B> > map(ReadMap<A,B>());
   202     MapToFunctor<ReadMap<A,B> > map = MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
   203 
   203 
   204     check(functorToMap(&func)[A()] == 3,
   204     check(functorToMap(&func)[A()] == 3,
   205           "Something is wrong with FunctorToMap");
   205           "Something is wrong with FunctorToMap");
   206     check(mapToFunctor(constMap<A,int>(2))(A()) == 2,
   206     check(mapToFunctor(constMap<A,int>(2))(A()) == 2,
   207           "Something is wrong with MapToFunctor");
   207           "Something is wrong with MapToFunctor");