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

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


Author: athos
Date: Tue May  4 10:31:48 2004
New Revision: 678

Added:
   hugo/trunk/src/test/xy_test.cc
      - copied, changed from r675, /hugo/trunk/src/work/athos/xy/xy_test.cc

Log:
Test file xy_test.cc finished.

Copied: hugo/trunk/src/test/xy_test.cc (from r675, /hugo/trunk/src/work/athos/xy/xy_test.cc)
==============================================================================
--- /hugo/trunk/src/work/athos/xy/xy_test.cc	(original)
+++ hugo/trunk/src/test/xy_test.cc	Tue May  4 10:31:48 2004
@@ -5,10 +5,12 @@
 
 bool passed = true;
 
-void check(bool rc) {
+void check(bool rc, char *msg="") {
   passed = passed && rc;
   if(!rc) {
-    cout << "Test failed!" << endl;
+    std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
+ 
+
   }
 }
 
@@ -29,23 +31,47 @@
 	check(seged.x==4 && seged.y==6);
 
 	seged = a-b;
-	check(seged.x==-1 && seged.y==-1);
+	check(seged.x==-2 && seged.y==-2, "a-b");
 
 	check(a.normSquare()==5);
-	check(a*b==11);
+	check(a*b==11, "a*b");
 
 	int l=2;
 	seged = a*l;
-	check(seged.x==2 && seged.y==4);
+	check(seged.x==2 && seged.y==4, "a*l");
 
 	seged = b/l;
-	check(seged.x==1 && seged.y==2);
+	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.");
+
+	BB doboz2(seged);
+	check(!doboz2.empty(), "empty? Should not be.");
+
+	doboz2 += doboz1;
+	check(doboz2.inside(seged),"Inside? Should be.");
+
 	cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
 	     << endl;
 



More information about the Lemon-commits mailing list