COIN-OR::LEMON - Graph Library

source: lemon-0.x/test/xy_test.cc @ 2058:0b1fc1566fdb

Last change on this file since 2058:0b1fc1566fdb was 2006:00d59f733817, checked in by Alpar Juttner, 18 years ago

Spellcheck

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