src/work/athos/xy/xy_test.cc
changeset 513 60afd11e6cb3
parent 240 4a1d2e642552
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/athos/xy/xy_test.cc	Mon May 03 14:42:40 2004 +0000
     1.3 @@ -0,0 +1,54 @@
     1.4 +#include <xy.h>
     1.5 +#include <iostream>
     1.6 +using namespace std;
     1.7 +using namespace hugo;
     1.8 +
     1.9 +bool passed = true;
    1.10 +
    1.11 +void check(bool rc) {
    1.12 +  passed = passed && rc;
    1.13 +  if(!rc) {
    1.14 +    cout << "Test failed!" << endl;
    1.15 +  }
    1.16 +}
    1.17 +
    1.18 +
    1.19 +
    1.20 +int main()
    1.21 +{
    1.22 +
    1.23 +
    1.24 +
    1.25 +	typedef xy<int> XY;
    1.26 +	
    1.27 +	XY seged;
    1.28 +	XY a(1,2);
    1.29 +	XY b(3,4);
    1.30 +
    1.31 +	seged = a+b;
    1.32 +	check(seged.x==4 && seged.y==6);
    1.33 +
    1.34 +	seged = a-b;
    1.35 +	check(seged.x==-1 && seged.y==-1);
    1.36 +
    1.37 +	check(a.normSquare()==5);
    1.38 +	check(a*b==11);
    1.39 +
    1.40 +	int l=2;
    1.41 +	seged = a*l;
    1.42 +	check(seged.x==2 && seged.y==4);
    1.43 +
    1.44 +	seged = b/l;
    1.45 +	check(seged.x==1 && seged.y==2);
    1.46 +
    1.47 +	typedef BoundingBox<int> BB;
    1.48 +	BB doboz1;
    1.49 +	doboz1 += a;
    1.50 +	doboz1 += b;
    1.51 +
    1.52 +	cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
    1.53 +	     << endl;
    1.54 +
    1.55 +	return passed ? 0 : 1;
    1.56 +
    1.57 +}