Changeset 171:02f4d5d9bfd7 in lemon for test/dim_test.cc
 Timestamp:
 06/15/08 22:05:23 (13 years ago)
 Branch:
 default
 Children:
 172:c94a80f38d7f, 173:b026e9779b28, 175:4eb8900a865c
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

test/dim_test.cc
r39 r171 26 26 int main() 27 27 { 28 cout << "Testing classes 'dim2::Point' and 'dim2::BoundingBox'." << endl;29 30 28 typedef dim2::Point<int> Point; 31 29 32 30 Point p; 33 check(p.size()==2, "Wrong vectorinitialization.");31 check(p.size()==2, "Wrong dim2::Point initialization."); 34 32 35 33 Point a(1,2); 36 34 Point b(3,4); 37 check(a[0]==1 && a[1]==2, "Wrong vectorinitialization.");35 check(a[0]==1 && a[1]==2, "Wrong dim2::Point initialization."); 38 36 39 37 p = a+b; 40 check(p.x==4 && p.y==6, "Wrong vectoraddition.");38 check(p.x==4 && p.y==6, "Wrong dim2::Point addition."); 41 39 42 40 p = ab; 43 check(p.x==2 && p.y==2, "Wrong vectorsubtraction.");41 check(p.x==2 && p.y==2, "Wrong dim2::Point subtraction."); 44 42 45 check(a.normSquare()==5,"Wrong vectornorm calculation.");46 check(a*b==11, "Wrong vectorscalar product.");43 check(a.normSquare()==5,"Wrong dim2::Point norm calculation."); 44 check(a*b==11, "Wrong dim2::Point scalar product."); 47 45 48 46 int l=2; 49 47 p = a*l; 50 check(p.x==2 && p.y==4, "Wrong vectormultiplication by a scalar.");48 check(p.x==2 && p.y==4, "Wrong dim2::Point multiplication by a scalar."); 51 49 52 50 p = b/l; 53 check(p.x==1 && p.y==2, "Wrong vectordivision by a scalar.");51 check(p.x==1 && p.y==2, "Wrong dim2::Point division by a scalar."); 54 52 55 53 typedef dim2::BoundingBox<int> BB; 56 54 BB box1; 57 check(box1.empty(), " It should be empty.");55 check(box1.empty(), "Wrong empty() in dim2::BoundingBox."); 58 56 59 57 box1.add(a); 60 check(!box1.empty(), " It should not be empty.");58 check(!box1.empty(), "Wrong empty() in dim2::BoundingBox."); 61 59 box1.add(b); 62 60 … … 65 63 box1.topRight().x==3 && 66 64 box1.topRight().y==4, 67 "Wrong addition of points to box.");65 "Wrong addition of points to dim2::BoundingBox."); 68 66 69 67 p.x=2; p.y=3; 70 check(box1.inside(p), " It should be inside.");68 check(box1.inside(p), "Wrong inside() in dim2::BoundingBox."); 71 69 72 70 p.x=1; p.y=3; 73 check(box1.inside(p), " It should be inside.");71 check(box1.inside(p), "Wrong inside() in dim2::BoundingBox."); 74 72 75 73 p.x=0; p.y=3; 76 check(!box1.inside(p), " It should not be inside.");74 check(!box1.inside(p), "Wrong inside() in dim2::BoundingBox."); 77 75 78 76 BB box2(p); 79 check(!box2.empty(), 80 "It should not be empty. Constructed from 1 point."); 77 check(!box2.empty(), "Wrong empty() in dim2::BoundingBox."); 81 78 82 79 box2.add(box1); 83 check(box2.inside(p), 84 "It should be inside. Incremented a box with another one."); 80 check(box2.inside(p), "Wrong inside() in dim2::BoundingBox."); 85 81 86 82 return 0;
Note: See TracChangeset
for help on using the changeset viewer.