alpar@209: /* -*- mode: C++; indent-tabs-mode: nil; -*- alpar@8: * alpar@209: * This file is a part of LEMON, a generic C++ optimization library. alpar@8: * alpar@39: * Copyright (C) 2003-2008 alpar@8: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@8: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@8: * alpar@8: * Permission to use, modify and distribute this software is granted alpar@8: * provided that this copyright notice appears in all copies. For alpar@8: * precise terms see the accompanying LICENSE file. alpar@8: * alpar@8: * This software is provided "AS IS" with no warranty of any kind, alpar@8: * express or implied, and with no claim as to its suitability for any alpar@8: * purpose. alpar@8: * alpar@8: */ alpar@8: alpar@8: #include alpar@8: #include alpar@8: #include "test_tools.h" alpar@8: alpar@8: using namespace std; alpar@8: using namespace lemon; kpeter@14: alpar@8: int main() alpar@8: { alpar@8: typedef dim2::Point Point; kpeter@14: kpeter@14: Point p; kpeter@171: check(p.size()==2, "Wrong dim2::Point initialization."); alpar@8: alpar@8: Point a(1,2); alpar@8: Point b(3,4); kpeter@171: check(a[0]==1 && a[1]==2, "Wrong dim2::Point initialization."); alpar@8: kpeter@14: p = a+b; kpeter@171: check(p.x==4 && p.y==6, "Wrong dim2::Point addition."); alpar@8: kpeter@14: p = a-b; kpeter@171: check(p.x==-2 && p.y==-2, "Wrong dim2::Point subtraction."); alpar@8: kpeter@171: check(a.normSquare()==5,"Wrong dim2::Point norm calculation."); kpeter@171: check(a*b==11, "Wrong dim2::Point scalar product."); alpar@8: alpar@8: int l=2; kpeter@14: p = a*l; kpeter@171: check(p.x==2 && p.y==4, "Wrong dim2::Point multiplication by a scalar."); alpar@8: kpeter@14: p = b/l; kpeter@171: check(p.x==1 && p.y==2, "Wrong dim2::Point division by a scalar."); alpar@8: alpar@8: typedef dim2::BoundingBox BB; kpeter@14: BB box1; kpeter@171: check(box1.empty(), "Wrong empty() in dim2::BoundingBox."); alpar@8: kpeter@14: box1.add(a); kpeter@171: check(!box1.empty(), "Wrong empty() in dim2::BoundingBox."); kpeter@14: box1.add(b); alpar@8: kpeter@14: check(box1.bottomLeft().x==1 && kpeter@14: box1.bottomLeft().y==2 && kpeter@14: box1.topRight().x==3 && kpeter@14: box1.topRight().y==4, kpeter@171: "Wrong addition of points to dim2::BoundingBox."); alpar@8: kpeter@14: p.x=2; p.y=3; kpeter@171: check(box1.inside(p), "Wrong inside() in dim2::BoundingBox."); alpar@8: kpeter@14: p.x=1; p.y=3; kpeter@171: check(box1.inside(p), "Wrong inside() in dim2::BoundingBox."); alpar@8: kpeter@14: p.x=0; p.y=3; kpeter@171: check(!box1.inside(p), "Wrong inside() in dim2::BoundingBox."); kpeter@14: kpeter@14: BB box2(p); kpeter@171: check(!box2.empty(), "Wrong empty() in dim2::BoundingBox."); alpar@8: kpeter@14: box2.add(box1); kpeter@171: check(box2.inside(p), "Wrong inside() in dim2::BoundingBox."); kpeter@14: kpeter@14: return 0; alpar@8: }