1.1 --- a/test/dim_test.cc Sun Jun 15 22:03:33 2008 +0200
1.2 +++ b/test/dim_test.cc Sun Jun 15 22:05:23 2008 +0200
1.3 @@ -25,63 +25,59 @@
1.4
1.5 int main()
1.6 {
1.7 - cout << "Testing classes 'dim2::Point' and 'dim2::BoundingBox'." << endl;
1.8 -
1.9 typedef dim2::Point<int> Point;
1.10
1.11 Point p;
1.12 - check(p.size()==2, "Wrong vector initialization.");
1.13 + check(p.size()==2, "Wrong dim2::Point initialization.");
1.14
1.15 Point a(1,2);
1.16 Point b(3,4);
1.17 - check(a[0]==1 && a[1]==2, "Wrong vector initialization.");
1.18 + check(a[0]==1 && a[1]==2, "Wrong dim2::Point initialization.");
1.19
1.20 p = a+b;
1.21 - check(p.x==4 && p.y==6, "Wrong vector addition.");
1.22 + check(p.x==4 && p.y==6, "Wrong dim2::Point addition.");
1.23
1.24 p = a-b;
1.25 - check(p.x==-2 && p.y==-2, "Wrong vector subtraction.");
1.26 + check(p.x==-2 && p.y==-2, "Wrong dim2::Point subtraction.");
1.27
1.28 - check(a.normSquare()==5,"Wrong vector norm calculation.");
1.29 - check(a*b==11, "Wrong vector scalar product.");
1.30 + check(a.normSquare()==5,"Wrong dim2::Point norm calculation.");
1.31 + check(a*b==11, "Wrong dim2::Point scalar product.");
1.32
1.33 int l=2;
1.34 p = a*l;
1.35 - check(p.x==2 && p.y==4, "Wrong vector multiplication by a scalar.");
1.36 + check(p.x==2 && p.y==4, "Wrong dim2::Point multiplication by a scalar.");
1.37
1.38 p = b/l;
1.39 - check(p.x==1 && p.y==2, "Wrong vector division by a scalar.");
1.40 + check(p.x==1 && p.y==2, "Wrong dim2::Point division by a scalar.");
1.41
1.42 typedef dim2::BoundingBox<int> BB;
1.43 BB box1;
1.44 - check(box1.empty(), "It should be empty.");
1.45 + check(box1.empty(), "Wrong empty() in dim2::BoundingBox.");
1.46
1.47 box1.add(a);
1.48 - check(!box1.empty(), "It should not be empty.");
1.49 + check(!box1.empty(), "Wrong empty() in dim2::BoundingBox.");
1.50 box1.add(b);
1.51
1.52 check(box1.bottomLeft().x==1 &&
1.53 box1.bottomLeft().y==2 &&
1.54 box1.topRight().x==3 &&
1.55 box1.topRight().y==4,
1.56 - "Wrong addition of points to box.");
1.57 + "Wrong addition of points to dim2::BoundingBox.");
1.58
1.59 p.x=2; p.y=3;
1.60 - check(box1.inside(p), "It should be inside.");
1.61 + check(box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
1.62
1.63 p.x=1; p.y=3;
1.64 - check(box1.inside(p), "It should be inside.");
1.65 + check(box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
1.66
1.67 p.x=0; p.y=3;
1.68 - check(!box1.inside(p), "It should not be inside.");
1.69 + check(!box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
1.70
1.71 BB box2(p);
1.72 - check(!box2.empty(),
1.73 - "It should not be empty. Constructed from 1 point.");
1.74 + check(!box2.empty(), "Wrong empty() in dim2::BoundingBox.");
1.75
1.76 box2.add(box1);
1.77 - check(box2.inside(p),
1.78 - "It should be inside. Incremented a box with another one.");
1.79 + check(box2.inside(p), "Wrong inside() in dim2::BoundingBox.");
1.80
1.81 return 0;
1.82 }