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