alpar@906: /* -*- C++ -*- alpar@906: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@2391: * Copyright (C) 2003-2007 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@2207: #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@2207: cout << "Testing classes `dim2::Point' and `dim2::BoundingBox'." << endl; athos@201: alpar@2207: typedef dim2::Point Point; athos@513: deba@2212: Point seged; deba@2212: check(seged.size()==2, "Wrong vector addition"); athos@201: deba@2212: Point a(1,2); deba@2212: Point b(3,4); athos@201: deba@2212: check(a[0]==1 && a[1]==2, "Wrong vector addition"); athos@513: deba@2212: seged = a+b; deba@2212: check(seged.x==4 && seged.y==6, "Wrong vector addition"); athos@513: deba@2212: seged = a-b; deba@2212: check(seged.x==-2 && seged.y==-2, "a-b"); athos@513: deba@2212: check(a.normSquare()==5,"Wrong norm calculation"); deba@2212: check(a*b==11, "a*b"); athos@513: deba@2212: int l=2; deba@2212: seged = a*l; deba@2212: check(seged.x==2 && seged.y==4, "a*l"); deba@2212: deba@2212: seged = b/l; deba@2212: check(seged.x==1 && seged.y==2, "b/l"); deba@2212: deba@2212: typedef dim2::BoundingBox BB; deba@2212: BB doboz1; deba@2212: check(doboz1.empty(), "It should be empty."); athos@516: deba@2212: doboz1.add(a); deba@2212: check(!doboz1.empty(), "It should not be empty."); deba@2212: doboz1.add(b); athos@513: deba@2212: check(doboz1.bottomLeft().x==1 && deba@2212: doboz1.bottomLeft().y==2 && deba@2212: doboz1.topRight().x==3 && deba@2212: doboz1.topRight().y==4, deba@2212: "added points to box"); athos@516: deba@2212: seged.x=2;seged.y=3; deba@2212: check(doboz1.inside(seged),"It should be inside."); athos@516: deba@2212: seged.x=1;seged.y=3; deba@2212: check(doboz1.inside(seged),"It should be inside."); athos@516: deba@2212: seged.x=0;seged.y=3; deba@2212: check(!doboz1.inside(seged),"It should not be inside."); athos@516: deba@2212: BB doboz2(seged); deba@2212: check(!doboz2.empty(), deba@2212: "It should not be empty. Constructed from 1 point."); athos@516: deba@2212: doboz2.add(doboz1); deba@2212: check(doboz2.inside(seged), deba@2212: "It should be inside. Incremented a box with another one."); athos@201: }