Changeset 210:81cfc04531e8 in lemon-1.0 for test
- Timestamp:
- 07/13/08 21:09:47 (16 years ago)
- Branch:
- default
- Children:
- 211:542dd614cbb4, 212:1ae84dea7d09, 214:60eecd3fe37a, 216:6d7bfcf5b48e
- Phase:
- public
- Location:
- test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
test/dijkstra_test.cc
r209 r210 111 111 Node u=G.source(e); 112 112 Node v=G.target(e); 113 check( !dijkstra_test.reached(u) || (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= length[e]), 114 "dist(target)-dist(source)-arc_length= " << dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]); 113 check( !dijkstra_test.reached(u) || 114 (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= length[e]), 115 "dist(target)-dist(source)-arc_length= " << 116 dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]); 115 117 } 116 118 … … 122 124 check(u==dijkstra_test.predNode(v),"Wrong tree."); 123 125 check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == length[e], 124 "Wrong distance! Difference: " << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e])); 126 "Wrong distance! Difference: " << 127 std::abs(dijkstra_test.dist(v)-dijkstra_test.dist(u)-length[e])); 125 128 } 126 129 } -
test/graph_utils_test.cc
r209 r210 93 93 Arc con3 = al3(src, trg); 94 94 Arc con4 = findArc(fg, src, trg); 95 check(con1 == con2 && con2 == con3 && con3 == con4, "Different results.") 95 check(con1 == con2 && con2 == con3 && con3 == con4, 96 "Different results.") 96 97 check(con1 != INVALID, "There is no connecting arc."); 97 98 check(fg.source(con1) == src, "Wrong source."); 98 99 check(fg.target(con1) == trg, "Wrong target."); 99 check(al3(src, trg, con3) == INVALID, "There is more connecting arc."); 100 check(findArc(fg, src, trg, con4) == INVALID, "There is more connecting arc."); 100 check(al3(src, trg, con3) == INVALID, 101 "There is more connecting arc."); 102 check(findArc(fg, src, trg, con4) == INVALID, 103 "There is more connecting arc."); 101 104 } 102 105 } … … 124 127 for (ConEdgeIt<Graph> con(graph, src, trg); con != INVALID; ++con) { 125 128 check( (graph.u(con) == src && graph.v(con) == trg) || 126 (graph.v(con) == src && graph.u(con) == trg), "Wrong end nodes."); 129 (graph.v(con) == src && graph.u(con) == trg), 130 "Wrong end nodes."); 127 131 ++found[con]; 128 132 check(found[con] <= 2, "The edge found more than twice."); -
test/maps_test.cc
r209 r210 104 104 map6 = constMap<A,int,10>(); 105 105 map7 = constMap<A,Const<int,10> >(); 106 check(map6[A()] == 10 && map7[A()] == 10, "Something is wrong with ConstMap"); 106 check(map6[A()] == 10 && map7[A()] == 10, 107 "Something is wrong with ConstMap"); 107 108 } 108 109 … … 115 116 116 117 checkConcept<ReadMap<double,double>, IdentityMap<double> >(); 117 check(identityMap<double>()[1.0] == 1.0 && identityMap<double>()[3.14] == 3.14, 118 check(identityMap<double>()[1.0] == 1.0 && 119 identityMap<double>()[3.14] == 3.14, 118 120 "Something is wrong with IdentityMap"); 119 121 } … … 156 158 SparseMap<double, int> map8 = sparseMap(m,10); 157 159 158 check(map5[1.0] == 0 && map5[3.14] == 0 && map6[1.0] == 10 && map6[3.14] == 10, 160 check(map5[1.0] == 0 && map5[3.14] == 0 && 161 map6[1.0] == 10 && map6[3.14] == 10, 159 162 "Something is wrong with SparseMap"); 160 163 map5[1.0] = map6[3.14] = 100; 161 check(map5[1.0] == 100 && map5[3.14] == 0 && map6[1.0] == 10 && map6[3.14] == 100, 164 check(map5[1.0] == 100 && map5[3.14] == 0 && 165 map6[1.0] == 10 && map6[3.14] == 100, 162 166 "Something is wrong with SparseMap"); 163 167 } … … 172 176 SparseMap<double, bool> m1(false); m1[3.14] = true; 173 177 RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14; 174 check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1], "Something is wrong with ComposeMap") 178 check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1], 179 "Something is wrong with ComposeMap") 175 180 } 176 181 … … 197 202 MapToFunctor<ReadMap<A,B> > map(ReadMap<A,B>()); 198 203 199 check(functorToMap(&func)[A()] == 3, "Something is wrong with FunctorToMap"); 200 check(mapToFunctor(constMap<A,int>(2))(A()) == 2, "Something is wrong with MapToFunctor"); 201 check(mapToFunctor(functorToMap(&func))(A()) == 3 && mapToFunctor(functorToMap(&func))[A()] == 3, 204 check(functorToMap(&func)[A()] == 3, 205 "Something is wrong with FunctorToMap"); 206 check(mapToFunctor(constMap<A,int>(2))(A()) == 2, 207 "Something is wrong with MapToFunctor"); 208 check(mapToFunctor(functorToMap(&func))(A()) == 3 && 209 mapToFunctor(functorToMap(&func))[A()] == 3, 202 210 "Something is wrong with FunctorToMap or MapToFunctor"); 203 211 check(functorToMap(mapToFunctor(constMap<A,int>(2)))[A()] == 2, … … 207 215 // ConvertMap 208 216 { 209 checkConcept<ReadMap<double,double>, ConvertMap<ReadMap<double, int>, double> >(); 217 checkConcept<ReadMap<double,double>, 218 ConvertMap<ReadMap<double, int>, double> >(); 210 219 ConvertMap<RangeMap<bool>, int> map1(rangeMap(1, true)); 211 220 ConvertMap<RangeMap<bool>, int> map2 = convertMap<int>(rangeMap(2, false)); … … 225 234 ForkMap<SM, RM> map2 = forkMap(m2,m1); 226 235 map2.set(5, 10); 227 check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 && m2[5] == 10 && map2[1] == -1 && map2[5] == 10, 236 check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 && 237 m2[5] == 10 && map2[1] == -1 && map2[5] == 10, 228 238 "Something is wrong with ForkMap"); 229 239 } … … 242 252 IdentityMap<int> im; 243 253 ConvertMap<IdentityMap<int>, double> id(im); 244 check(addMap(c1,id)[0] == 1.0 && addMap(c1,id)[10] == 11.0, "Something is wrong with AddMap"); 245 check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0, "Something is wrong with SubMap"); 246 check(mulMap(id,c2)[0] == 0 && mulMap(id,c2)[2] == 6.28, "Something is wrong with MulMap"); 247 check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2] == 1.57, "Something is wrong with DivMap"); 254 check(addMap(c1,id)[0] == 1.0 && addMap(c1,id)[10] == 11.0, 255 "Something is wrong with AddMap"); 256 check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0, 257 "Something is wrong with SubMap"); 258 check(mulMap(id,c2)[0] == 0 && mulMap(id,c2)[2] == 6.28, 259 "Something is wrong with MulMap"); 260 check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2] == 1.57, 261 "Something is wrong with DivMap"); 248 262 249 263 checkConcept<DoubleMap, ShiftMap<DoubleMap> >(); … … 257 271 check(shiftMap(id, 2.0)[1] == 3.0 && shiftMap(id, 2.0)[10] == 12.0, 258 272 "Something is wrong with ShiftMap"); 259 check(shiftWriteMap(id, 2.0)[1] == 3.0 && shiftWriteMap(id, 2.0)[10] == 12.0, 273 check(shiftWriteMap(id, 2.0)[1] == 3.0 && 274 shiftWriteMap(id, 2.0)[10] == 12.0, 260 275 "Something is wrong with ShiftWriteMap"); 261 276 check(scaleMap(id, 2.0)[1] == 2.0 && scaleMap(id, 2.0)[10] == 20.0, 262 277 "Something is wrong with ScaleMap"); 263 check(scaleWriteMap(id, 2.0)[1] == 2.0 && scaleWriteMap(id, 2.0)[10] == 20.0, 278 check(scaleWriteMap(id, 2.0)[1] == 2.0 && 279 scaleWriteMap(id, 2.0)[10] == 20.0, 264 280 "Something is wrong with ScaleWriteMap"); 265 281 check(negMap(id)[1] == -1.0 && negMap(id)[-10] == 10.0, … … 290 306 RangeMap<bool> rm(2); 291 307 rm[0] = true; rm[1] = false; 292 check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] && !andMap(fm,rm)[0] && !andMap(fm,rm)[1], 308 check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] && 309 !andMap(fm,rm)[0] && !andMap(fm,rm)[1], 293 310 "Something is wrong with AndMap"); 294 check(orMap(tm,rm)[0] && orMap(tm,rm)[1] && orMap(fm,rm)[0] && !orMap(fm,rm)[1], 311 check(orMap(tm,rm)[0] && orMap(tm,rm)[1] && 312 orMap(fm,rm)[0] && !orMap(fm,rm)[1], 295 313 "Something is wrong with OrMap"); 296 check(!notMap(rm)[0] && notMap(rm)[1], "Something is wrong with NotMap"); 297 check(!notWriteMap(rm)[0] && notWriteMap(rm)[1], "Something is wrong with NotWriteMap"); 314 check(!notMap(rm)[0] && notMap(rm)[1], 315 "Something is wrong with NotMap"); 316 check(!notWriteMap(rm)[0] && notWriteMap(rm)[1], 317 "Something is wrong with NotWriteMap"); 298 318 299 319 ConstMap<int, double> cm(2.0); … … 311 331 vec v1; 312 332 vec v2(10); 313 LoggerBoolMap<std::back_insert_iterator<vec> > map1(std::back_inserter(v1)); 333 LoggerBoolMap<std::back_insert_iterator<vec> > 334 map1(std::back_inserter(v1)); 314 335 LoggerBoolMap<vec::iterator> map2(v2.begin()); 315 336 map1.set(10, false); … … 319 340 map1.set(60, true); map2.set(60, true); 320 341 check(v1.size() == 3 && v2.size() == 10 && 321 v1[0]==20 && v1[1]==50 && v1[2]==60 && v2[0]==20 && v2[1]==50 && v2[2]==60, 342 v1[0]==20 && v1[1]==50 && v1[2]==60 && 343 v2[0]==20 && v2[1]==50 && v2[2]==60, 322 344 "Something is wrong with LoggerBoolMap"); 323 345
Note: See TracChangeset
for help on using the changeset viewer.