test/dim_test.cc
changeset 354 80a4d0742e98
parent 209 765619b7cbb2
child 253 dbe309b5e855
equal deleted inserted replaced
4:7b810630fe6a 5:a351b8e24ff7
    56 
    56 
    57   box1.add(a);
    57   box1.add(a);
    58   check(!box1.empty(), "Wrong empty() in dim2::BoundingBox.");
    58   check(!box1.empty(), "Wrong empty() in dim2::BoundingBox.");
    59   box1.add(b);
    59   box1.add(b);
    60 
    60 
    61   check(box1.bottomLeft().x==1 &&
    61   check(box1.left()==1 && box1.bottom()==2 &&
    62         box1.bottomLeft().y==2 &&
    62         box1.right()==3 && box1.top()==4,
    63         box1.topRight().x==3 &&
       
    64         box1.topRight().y==4,
       
    65         "Wrong addition of points to dim2::BoundingBox.");
    63         "Wrong addition of points to dim2::BoundingBox.");
    66 
    64 
    67   p.x=2; p.y=3;
    65   check(box1.inside(Point(2,3)), "Wrong inside() in dim2::BoundingBox.");
    68   check(box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
    66   check(box1.inside(Point(1,3)), "Wrong inside() in dim2::BoundingBox.");
       
    67   check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::BoundingBox.");
    69 
    68 
    70   p.x=1; p.y=3;
    69   BB box2(Point(2,2));
    71   check(box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
       
    72 
       
    73   p.x=0; p.y=3;
       
    74   check(!box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
       
    75 
       
    76   BB box2(p);
       
    77   check(!box2.empty(), "Wrong empty() in dim2::BoundingBox.");
    70   check(!box2.empty(), "Wrong empty() in dim2::BoundingBox.");
    78 
    71   
    79   box2.add(box1);
    72   box2.bottomLeft(Point(2,0));
    80   check(box2.inside(p), "Wrong inside() in dim2::BoundingBox.");
    73   box2.topRight(Point(5,3));
       
    74   BB box3 = box1 & box2;
       
    75   check(!box3.empty() &&
       
    76         box3.left()==2 && box3.bottom()==2 && 
       
    77         box3.right()==3 && box3.top()==3,
       
    78         "Wrong intersection of two dim2::BoundingBox objects.");
       
    79   
       
    80   box1.add(box2);
       
    81   check(!box1.empty() &&
       
    82         box1.left()==1 && box1.bottom()==0 &&
       
    83         box1.right()==5 && box1.top()==4,
       
    84         "Wrong addition of two dim2::BoundingBox objects.");
    81 
    85 
    82   return 0;
    86   return 0;
    83 }
    87 }