[Lemon-commits] [lemon_svn] athos: r682 - hugo/trunk/src/test

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:40:56 CET 2006


Author: athos
Date: Tue May  4 11:00:11 2004
New Revision: 682

Added:
   hugo/trunk/src/test/minlengthpaths_test.cc
      - copied, changed from r679, /hugo/trunk/src/test/xy_test.cc
Modified:
   hugo/trunk/src/test/xy_test.cc

Log:
Started minlengthpaths_test, but it should not be here

Copied: hugo/trunk/src/test/minlengthpaths_test.cc (from r679, /hugo/trunk/src/test/xy_test.cc)
==============================================================================
--- /hugo/trunk/src/test/xy_test.cc	(original)
+++ hugo/trunk/src/test/minlengthpaths_test.cc	Tue May  4 11:00:11 2004
@@ -1,8 +1,16 @@
-#include <xy.h>
 #include <iostream>
+#include <list_graph.h>
+#include <minlengthpaths.h>
 using namespace std;
 using namespace hugo;
 
+
+
+int main()
+{
+
+  
+
 bool passed = true;
 
 void check(bool rc, char *msg="") {
@@ -19,62 +27,54 @@
 int main()
 {
 
+  typedef ListGraph::Node Node;
+  typedef ListGraph::Edge Edge;
 
+  ListGraph graph;
 
-	typedef xy<int> XY;
-	
-	XY seged;
-	XY a(1,2);
-	XY b(3,4);
-
-	seged = a+b;
-	check(seged.x==4 && seged.y==6);
-
-	seged = a-b;
-	check(seged.x==-2 && seged.y==-2, "a-b");
-
-	check(a.normSquare()==5);
-	check(a*b==11, "a*b");
-
-	int l=2;
-	seged = a*l;
-	check(seged.x==2 && seged.y==4, "a*l");
-
-	seged = b/l;
-	check(seged.x==1 && seged.y==2, "b/l");
-
-	typedef BoundingBox<int> BB;
-	BB doboz1;
-	check(doboz1.empty(), "empty? Should be.");
-	
-	doboz1 += a;
-	check(!doboz1.empty(), "empty? Should not be.");
-	doboz1 += b;
-
-	check(doboz1.bottomLeft().x==1 && 
-	      doboz1.bottomLeft().y==2 &&
-	      doboz1.topRight().x==3 && 
-	      doboz1.topRight().y==4,  
-	      "added points to box");
-
-	seged.x=2;seged.y=3;
-	check(doboz1.inside(seged),"Inside? Should be.");
-
-	seged.x=1;seged.y=3;
-	check(doboz1.inside(seged),"Inside? Should be.");
-
-	seged.x=0;seged.y=3;
-	check(!doboz1.inside(seged),"Inside? Should not be.");
+  //Ahuja könyv példája
 
-	BB doboz2(seged);
-	check(!doboz2.empty(), "empty? Should not be. Constructed from 1 point.");
+  Node s=graph.addNode();
+  Node v2=graph.addNode();
+  Node v3=graph.addNode();
+  Node v4=graph.addNode();
+  Node v5=graph.addNode();
+  Node t=graph.addNode();
+
+  Edge s_v2=graph.addEdge(s, v2);
+  Edge s_v3=graph.addEdge(s, v3);
+  Edge v2_v4=graph.addEdge(v2, v4);
+  Edge v2_v5=graph.addEdge(v2, v5);
+  Edge v3_v5=graph.addEdge(v3, v5);
+  Edge v4_t=graph.addEdge(v4, t);
+  Edge v5_t=graph.addEdge(v5, t);
+  
+
+  ListGraph::EdgeMap<int> length(graph);
+
+  length.set(s_v2, 10);
+  length.set(s_v3, 10);
+  length.set(v2_v4, 5);
+  length.set(v2_v5, 1);
+  length.set(v3_v5, 5);
+  length.set(v4_t, 8);
+  length.set(v5_t, 8);
+
+  std::cout << "Minlengthpaths algorithm test..." << std::endl;
+
+  
+  int k=3;
+  MinLengthPaths<ListGraph, ListGraph::EdgeMap<int> >
+    surb_test(graph, length);
+
+  check(  surb_test.run(s,t,k) == 2 && suurb_test.totalLength == 46,"Two paths, total length should be 46");
 
-	doboz2 += doboz1;
-	check(doboz2.inside(seged),"Inside? Should be. Incremented a box with an other.");
+  k=1;
+  check(  surb_test.run(s,t,k) == 1 && suurb_test.totalLength == 19,"One path, total length should be 19");
 
-	cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
-	     << endl;
+  cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
+       << endl;
 
-	return passed ? 0 : 1;
+  return passed ? 0 : 1;
 
 }

Modified: hugo/trunk/src/test/xy_test.cc
==============================================================================
--- hugo/trunk/src/test/xy_test.cc	(original)
+++ hugo/trunk/src/test/xy_test.cc	Tue May  4 11:00:11 2004
@@ -19,7 +19,7 @@
 int main()
 {
 
-
+  cout << "Testing classes xy and boundingbox." << endl;
 
 	typedef xy<int> XY;
 	



More information about the Lemon-commits mailing list