test/maps_test.cc
changeset 535 6a17a722b50e
parent 440 88ed40ad0d4f
child 684 7b1a6e963018
child 693 7bda7860e0a8
equal deleted inserted replaced
11:f4138499bfef 12:7c1e8eb00d0c
   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");