COIN-OR::LEMON - Graph Library

source: lemon-0.x/test/xy_test.cc @ 1440:3d2e3cfb2a6c

Last change on this file since 1440:3d2e3cfb2a6c was 1435:8e85e6bbefdf, checked in by Akos Ladanyi, 19 years ago

trunk/src/* move to trunk/

File size: 1.9 KB
RevLine 
[906]1/* -*- C++ -*-
[1435]2 * test/xy_test.cc - Part of LEMON, a generic C++ optimization library
[906]3 *
[1164]4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
[1359]5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
[906]6 *
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
10 *
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
13 * purpose.
14 *
15 */
16
[921]17#include <lemon/xy.h>
[201]18#include <iostream>
[727]19#include "test_tools.h"
20
[201]21using namespace std;
[921]22using namespace lemon;
[201]23int main()
24{
[207]25
[774]26  cout << "Testing classes `xy' and `boundingbox'." << endl;
[201]27
[513]28        typedef xy<int> XY;
29       
30        XY seged;
31        XY a(1,2);
32        XY b(3,4);
[201]33
[513]34        seged = a+b;
[727]35        check(seged.x==4 && seged.y==6, "Wrong vector addition");
[201]36
[513]37        seged = a-b;
[516]38        check(seged.x==-2 && seged.y==-2, "a-b");
[513]39
[727]40        check(a.normSquare()==5,"Wrong norm calculation");
[516]41        check(a*b==11, "a*b");
[513]42
43        int l=2;
44        seged = a*l;
[516]45        check(seged.x==2 && seged.y==4, "a*l");
[513]46
47        seged = b/l;
[516]48        check(seged.x==1 && seged.y==2, "b/l");
[513]49
50        typedef BoundingBox<int> BB;
51        BB doboz1;
[774]52        check(doboz1.empty(), "It should be empty.");
[516]53       
[513]54        doboz1 += a;
[774]55        check(!doboz1.empty(), "It should not be empty.");
[513]56        doboz1 += b;
57
[516]58        check(doboz1.bottomLeft().x==1 &&
59              doboz1.bottomLeft().y==2 &&
60              doboz1.topRight().x==3 &&
61              doboz1.topRight().y==4, 
62              "added points to box");
63
64        seged.x=2;seged.y=3;
[774]65        check(doboz1.inside(seged),"It should be inside.");
[516]66
67        seged.x=1;seged.y=3;
[774]68        check(doboz1.inside(seged),"It should be inside.");
[516]69
70        seged.x=0;seged.y=3;
[774]71        check(!doboz1.inside(seged),"It should not be inside.");
[516]72
73        BB doboz2(seged);
[727]74        check(!doboz2.empty(),
[774]75              "It should not be empty. Constructed from 1 point.");
[516]76
77        doboz2 += doboz1;
[727]78        check(doboz2.inside(seged),
[774]79              "It should be inside. Incremented a box with an other.");
[201]80}
Note: See TracBrowser for help on using the repository browser.