Some more test cases.
authoralpar
Sat, 08 May 2004 16:00:57 +0000
changeset 58587c34740a0ec
parent 584 1d4855f5312e
child 586 04fdffd38e89
Some more test cases.
src/test/dijkstra_test.cc
     1.1 --- a/src/test/dijkstra_test.cc	Sat May 08 15:58:34 2004 +0000
     1.2 +++ b/src/test/dijkstra_test.cc	Sat May 08 16:00:57 2004 +0000
     1.3 @@ -73,5 +73,26 @@
     1.4    dijkstra_test.run(s);
     1.5    
     1.6    check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
     1.7 -  
     1.8 +
     1.9 +
    1.10 +  for(EdgeIt e(G); G.valid(e); G.next(e)) {
    1.11 +    Node u=G.tail(e);
    1.12 +    Node v=G.head(e);
    1.13 +    check( !dijkstra_test.reached(u) ||
    1.14 +	   (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= cap[e]),
    1.15 +	   "dist(head)-dist(tail)- edge_length= " 
    1.16 +	   << dijkstra_test.dist(v) - dijkstra_test.dist(u) 
    1.17 +	   - cap[e]);
    1.18 +  }
    1.19 +
    1.20 +  ///\bug This works only for integer lengths
    1.21 +  for(NodeIt v(G); G.valid(v); G.next(v))
    1.22 +    if ( dijkstra_test.reached(v) ) {
    1.23 +      Edge e=dijkstra_test.pred(v);
    1.24 +      Node u=G.tail(e);
    1.25 +      check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == cap[e],
    1.26 +	    "Bad shortest path tree edge! Difference: " 
    1.27 +	    << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) 
    1.28 +			    - cap[e]));
    1.29 +    }
    1.30  }