test/dim_test.cc
branch1.0
changeset 1123 351009ebb624
parent 242 dbe3fc9c875d
child 463 88ed40ad0d4f
equal deleted inserted replaced
5:a351b8e24ff7 6:f29a81f1d4c5
    48   check(p.x==2 && p.y==4, "Wrong dim2::Point multiplication by a scalar.");
    48   check(p.x==2 && p.y==4, "Wrong dim2::Point multiplication by a scalar.");
    49 
    49 
    50   p = b/l;
    50   p = b/l;
    51   check(p.x==1 && p.y==2, "Wrong dim2::Point division by a scalar.");
    51   check(p.x==1 && p.y==2, "Wrong dim2::Point division by a scalar.");
    52 
    52 
    53   typedef dim2::BoundingBox<int> BB;
    53   typedef dim2::Box<int> Box;
    54   BB box1;
    54   Box box1;
    55   check(box1.empty(), "Wrong empty() in dim2::BoundingBox.");
    55   check(box1.empty(), "Wrong empty() in dim2::Box.");
    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::Box.");
    59   box1.add(b);
    59   box1.add(b);
    60 
    60 
    61   check(box1.left()==1 && box1.bottom()==2 &&
    61   check(box1.left()==1 && box1.bottom()==2 &&
    62         box1.right()==3 && box1.top()==4,
    62         box1.right()==3 && box1.top()==4,
    63         "Wrong addition of points to dim2::BoundingBox.");
    63         "Wrong addition of points to dim2::Box.");
    64 
    64 
    65   check(box1.inside(Point(2,3)), "Wrong inside() in dim2::BoundingBox.");
    65   check(box1.inside(Point(2,3)), "Wrong inside() in dim2::Box.");
    66   check(box1.inside(Point(1,3)), "Wrong inside() in dim2::BoundingBox.");
    66   check(box1.inside(Point(1,3)), "Wrong inside() in dim2::Box.");
    67   check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::BoundingBox.");
    67   check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::Box.");
    68 
    68 
    69   BB box2(Point(2,2));
    69   Box box2(Point(2,2));
    70   check(!box2.empty(), "Wrong empty() in dim2::BoundingBox.");
    70   check(!box2.empty(), "Wrong empty() in dim2::Box.");
    71   
    71 
    72   box2.bottomLeft(Point(2,0));
    72   box2.bottomLeft(Point(2,0));
    73   box2.topRight(Point(5,3));
    73   box2.topRight(Point(5,3));
    74   BB box3 = box1 & box2;
    74   Box box3 = box1 & box2;
    75   check(!box3.empty() &&
    75   check(!box3.empty() &&
    76         box3.left()==2 && box3.bottom()==2 && 
    76         box3.left()==2 && box3.bottom()==2 &&
    77         box3.right()==3 && box3.top()==3,
    77         box3.right()==3 && box3.top()==3,
    78         "Wrong intersection of two dim2::BoundingBox objects.");
    78         "Wrong intersection of two dim2::Box objects.");
    79   
    79 
    80   box1.add(box2);
    80   box1.add(box2);
    81   check(!box1.empty() &&
    81   check(!box1.empty() &&
    82         box1.left()==1 && box1.bottom()==0 &&
    82         box1.left()==1 && box1.bottom()==0 &&
    83         box1.right()==5 && box1.top()==4,
    83         box1.right()==5 && box1.top()==4,
    84         "Wrong addition of two dim2::BoundingBox objects.");
    84         "Wrong addition of two dim2::Box objects.");
    85 
    85 
    86   return 0;
    86   return 0;
    87 }
    87 }