test/dim_test.cc
 changeset 14 8685efdef52f parent 8 a1b1d672f37a child 39 0a01d811071f
```     1.1 --- a/test/dim_test.cc	Sat Dec 22 07:01:20 2007 +0000
1.2 +++ b/test/dim_test.cc	Wed Jan 02 03:55:00 2008 +0100
1.3 @@ -22,65 +22,66 @@
1.4
1.5  using namespace std;
1.6  using namespace lemon;
1.7 +
1.8  int main()
1.9  {
1.10 -
1.11 -  cout << "Testing classes `dim2::Point' and `dim2::BoundingBox'." << endl;
1.12 +  cout << "Testing classes 'dim2::Point' and 'dim2::BoundingBox'." << endl;
1.13
1.14    typedef dim2::Point<int> Point;
1.15 -
1.16 -  Point seged;
1.17 -  check(seged.size()==2, "Wrong vector addition");
1.18 +
1.19 +  Point p;
1.20 +  check(p.size()==2, "Wrong vector initialization.");
1.21
1.22    Point a(1,2);
1.23    Point b(3,4);
1.24 +  check(a[0]==1 && a[1]==2, "Wrong vector initialization.");
1.25
1.26 -  check(a[0]==1 && a[1]==2, "Wrong vector addition");
1.27 +  p = a+b;
1.28 +  check(p.x==4 && p.y==6, "Wrong vector addition.");
1.29
1.30 -  seged = a+b;
1.31 -  check(seged.x==4 && seged.y==6, "Wrong vector addition");
1.32 +  p = a-b;
1.33 +  check(p.x==-2 && p.y==-2, "Wrong vector subtraction.");
1.34
1.35 -  seged = a-b;
1.36 -  check(seged.x==-2 && seged.y==-2, "a-b");
1.37 -
1.38 -  check(a.normSquare()==5,"Wrong norm calculation");
1.39 -  check(a*b==11, "a*b");
1.40 +  check(a.normSquare()==5,"Wrong vector norm calculation.");
1.41 +  check(a*b==11, "Wrong vector scalar product.");
1.42
1.43    int l=2;
1.44 -  seged = a*l;
1.45 -  check(seged.x==2 && seged.y==4, "a*l");
1.46 +  p = a*l;
1.47 +  check(p.x==2 && p.y==4, "Wrong vector multiplication by a scalar.");
1.48
1.49 -  seged = b/l;
1.50 -  check(seged.x==1 && seged.y==2, "b/l");
1.51 +  p = b/l;
1.52 +  check(p.x==1 && p.y==2, "Wrong vector division by a scalar.");
1.53
1.54    typedef dim2::BoundingBox<int> BB;
1.55 -  BB doboz1;
1.56 -  check(doboz1.empty(), "It should be empty.");
1.57 -
1.59 -  check(!doboz1.empty(), "It should not be empty.");
1.61 +  BB box1;
1.62 +  check(box1.empty(), "It should be empty.");
1.63
1.64 -  check(doboz1.bottomLeft().x==1 &&
1.65 -        doboz1.bottomLeft().y==2 &&
1.66 -        doboz1.topRight().x==3 &&
1.67 -        doboz1.topRight().y==4,
1.68 -        "added points to box");
1.70 +  check(!box1.empty(), "It should not be empty.");
1.72
1.73 -  seged.x=2;seged.y=3;
1.74 -  check(doboz1.inside(seged),"It should be inside.");
1.75 +  check(box1.bottomLeft().x==1 &&
1.76 +        box1.bottomLeft().y==2 &&
1.77 +        box1.topRight().x==3 &&
1.78 +        box1.topRight().y==4,
1.79 +        "Wrong addition of points to box.");
1.80
1.81 -  seged.x=1;seged.y=3;
1.82 -  check(doboz1.inside(seged),"It should be inside.");
1.83 +  p.x=2; p.y=3;
1.84 +  check(box1.inside(p), "It should be inside.");
1.85
1.86 -  seged.x=0;seged.y=3;
1.87 -  check(!doboz1.inside(seged),"It should not be inside.");
1.88 +  p.x=1; p.y=3;
1.89 +  check(box1.inside(p), "It should be inside.");
1.90
1.91 -  BB doboz2(seged);
1.92 -  check(!doboz2.empty(),
1.93 +  p.x=0; p.y=3;
1.94 +  check(!box1.inside(p), "It should not be inside.");
1.95 +
1.96 +  BB box2(p);
1.97 +  check(!box2.empty(),
1.98          "It should not be empty. Constructed from 1 point.");
1.99