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