test/dim_test.cc
changeset 242 dbe3fc9c875d
parent 209 765619b7cbb2
child 253 dbe309b5e855
     1.1 --- a/test/dim_test.cc	Tue Jul 29 14:41:16 2008 +0200
     1.2 +++ b/test/dim_test.cc	Tue Jul 29 14:41:55 2008 +0200
     1.3 @@ -58,26 +58,30 @@
     1.4    check(!box1.empty(), "Wrong empty() in dim2::BoundingBox.");
     1.5    box1.add(b);
     1.6  
     1.7 -  check(box1.bottomLeft().x==1 &&
     1.8 -        box1.bottomLeft().y==2 &&
     1.9 -        box1.topRight().x==3 &&
    1.10 -        box1.topRight().y==4,
    1.11 +  check(box1.left()==1 && box1.bottom()==2 &&
    1.12 +        box1.right()==3 && box1.top()==4,
    1.13          "Wrong addition of points to dim2::BoundingBox.");
    1.14  
    1.15 -  p.x=2; p.y=3;
    1.16 -  check(box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
    1.17 +  check(box1.inside(Point(2,3)), "Wrong inside() in dim2::BoundingBox.");
    1.18 +  check(box1.inside(Point(1,3)), "Wrong inside() in dim2::BoundingBox.");
    1.19 +  check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::BoundingBox.");
    1.20  
    1.21 -  p.x=1; p.y=3;
    1.22 -  check(box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
    1.23 -
    1.24 -  p.x=0; p.y=3;
    1.25 -  check(!box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
    1.26 -
    1.27 -  BB box2(p);
    1.28 +  BB box2(Point(2,2));
    1.29    check(!box2.empty(), "Wrong empty() in dim2::BoundingBox.");
    1.30 -
    1.31 -  box2.add(box1);
    1.32 -  check(box2.inside(p), "Wrong inside() in dim2::BoundingBox.");
    1.33 +  
    1.34 +  box2.bottomLeft(Point(2,0));
    1.35 +  box2.topRight(Point(5,3));
    1.36 +  BB box3 = box1 & box2;
    1.37 +  check(!box3.empty() &&
    1.38 +        box3.left()==2 && box3.bottom()==2 && 
    1.39 +        box3.right()==3 && box3.top()==3,
    1.40 +        "Wrong intersection of two dim2::BoundingBox objects.");
    1.41 +  
    1.42 +  box1.add(box2);
    1.43 +  check(!box1.empty() &&
    1.44 +        box1.left()==1 && box1.bottom()==0 &&
    1.45 +        box1.right()==5 && box1.top()==4,
    1.46 +        "Wrong addition of two dim2::BoundingBox objects.");
    1.47  
    1.48    return 0;
    1.49  }