Changeset 82:bce6c8f93d10 in lemon-1.0 for test/maps_test.cc
- Timestamp:
- 03/15/08 23:39:41 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/maps_test.cc
r80 r82 79 79 map1 = constMap<A>(B()); 80 80 map1.setAll(B()); 81 81 82 82 checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >(); 83 83 check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap"); … … 96 96 IdentityMap<A> map2 = map1; 97 97 map1 = identityMap<A>(); 98 98 99 99 checkConcept<ReadMap<double,double>, IdentityMap<double> >(); 100 100 check(identityMap<double>()[1.0] == 1.0 && identityMap<double>()[3.14] == 3.14, … … 152 152 CompMap map1(DoubleMap(),ReadMap<B,A>()); 153 153 CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>()); 154 154 155 155 SparseMap<double, bool> m1(false); m1[3.14] = true; 156 156 RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14; … … 198 198 { 199 199 checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >(); 200 200 201 201 typedef RangeMap<double> RM; 202 202 typedef SparseMap<int, double> SM; … … 211 211 "Something is wrong with ForkMap"); 212 212 } 213 213 214 214 // Arithmetic maps: 215 215 // - AddMap, SubMap, MulMap, DivMap … … 221 221 checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >(); 222 222 checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >(); 223 223 224 224 ConstMap<int, double> c1(1.0), c2(3.14); 225 225 IdentityMap<int> im; … … 229 229 check(mulMap(id,c2)[0] == 0 && mulMap(id,c2)[2] == 6.28, "Something is wrong with MulMap"); 230 230 check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2] == 1.57, "Something is wrong with DivMap"); 231 231 232 232 checkConcept<DoubleMap, ShiftMap<DoubleMap> >(); 233 233 checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >(); … … 253 253 "Something is wrong with AbsMap"); 254 254 } 255 256 // Logical maps 257 { 255 256 // Logical maps: 257 // - TrueMap, FalseMap 258 // - AndMap, OrMap 259 // - NotMap, NotWriteMap 260 // - EqualMap, LessMap 261 { 262 checkConcept<BoolMap, TrueMap<A> >(); 263 checkConcept<BoolMap, FalseMap<A> >(); 264 checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >(); 265 checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >(); 258 266 checkConcept<BoolMap, NotMap<BoolMap> >(); 259 267 checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >(); 260 268 checkConcept<BoolMap, EqualMap<DoubleMap,DoubleMap> >(); 269 checkConcept<BoolMap, LessMap<DoubleMap,DoubleMap> >(); 270 271 TrueMap<int> tm; 272 FalseMap<int> fm; 261 273 RangeMap<bool> rm(2); 262 274 rm[0] = true; rm[1] = false; 263 check(!(notMap(rm)[0]) && notMap(rm)[1], "Something is wrong with NotMap"); 264 check(!(notWriteMap(rm)[0]) && notWriteMap(rm)[1], "Something is wrong with NotWriteMap"); 275 check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] && !andMap(fm,rm)[0] && !andMap(fm,rm)[1], 276 "Something is wrong with AndMap"); 277 check(orMap(tm,rm)[0] && orMap(tm,rm)[1] && orMap(fm,rm)[0] && !orMap(fm,rm)[1], 278 "Something is wrong with OrMap"); 279 check(!notMap(rm)[0] && notMap(rm)[1], "Something is wrong with NotMap"); 280 check(!notWriteMap(rm)[0] && notWriteMap(rm)[1], "Something is wrong with NotWriteMap"); 281 282 ConstMap<int, double> cm(2.0); 283 IdentityMap<int> im; 284 ConvertMap<IdentityMap<int>, double> id(im); 285 check(lessMap(id,cm)[1] && !lessMap(id,cm)[2] && !lessMap(id,cm)[3], 286 "Something is wrong with LessMap"); 287 check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3], 288 "Something is wrong with EqualMap"); 265 289 } 266 290
Note: See TracChangeset
for help on using the changeset viewer.