alpar@906: /* -*- C++ -*- alpar@906: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@1956: * Copyright (C) 2003-2006 alpar@1956: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1359: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@906: * alpar@906: * Permission to use, modify and distribute this software is granted alpar@906: * provided that this copyright notice appears in all copies. For alpar@906: * precise terms see the accompanying LICENSE file. alpar@906: * alpar@906: * This software is provided "AS IS" with no warranty of any kind, alpar@906: * express or implied, and with no claim as to its suitability for any alpar@906: * purpose. alpar@906: * alpar@906: */ alpar@906: alpar@921: #include athos@201: #include alpar@727: #include "test_tools.h" alpar@727: athos@201: using namespace std; alpar@921: using namespace lemon; athos@201: int main() athos@201: { athos@207: alpar@774: cout << "Testing classes `xy' and `boundingbox'." << endl; athos@201: athos@513: typedef xy XY; athos@513: athos@513: XY seged; athos@513: XY a(1,2); athos@513: XY b(3,4); athos@201: athos@513: seged = a+b; alpar@727: check(seged.x==4 && seged.y==6, "Wrong vector addition"); athos@201: athos@513: seged = a-b; athos@516: check(seged.x==-2 && seged.y==-2, "a-b"); athos@513: alpar@727: check(a.normSquare()==5,"Wrong norm calculation"); athos@516: check(a*b==11, "a*b"); athos@513: athos@513: int l=2; athos@513: seged = a*l; athos@516: check(seged.x==2 && seged.y==4, "a*l"); athos@513: athos@513: seged = b/l; athos@516: check(seged.x==1 && seged.y==2, "b/l"); athos@513: athos@513: typedef BoundingBox BB; athos@513: BB doboz1; alpar@774: check(doboz1.empty(), "It should be empty."); athos@516: alpar@1588: doboz1.add(a); alpar@774: check(!doboz1.empty(), "It should not be empty."); alpar@1588: doboz1.add(b); athos@513: athos@516: check(doboz1.bottomLeft().x==1 && athos@516: doboz1.bottomLeft().y==2 && athos@516: doboz1.topRight().x==3 && athos@516: doboz1.topRight().y==4, athos@516: "added points to box"); athos@516: athos@516: seged.x=2;seged.y=3; alpar@774: check(doboz1.inside(seged),"It should be inside."); athos@516: athos@516: seged.x=1;seged.y=3; alpar@774: check(doboz1.inside(seged),"It should be inside."); athos@516: athos@516: seged.x=0;seged.y=3; alpar@774: check(!doboz1.inside(seged),"It should not be inside."); athos@516: athos@516: BB doboz2(seged); alpar@727: check(!doboz2.empty(), alpar@774: "It should not be empty. Constructed from 1 point."); athos@516: alpar@1588: doboz2.add(doboz1); alpar@727: check(doboz2.inside(seged), alpar@2006: "It should be inside. Incremented a box with another one."); athos@201: }