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