src/test/xy_test.cc
author alpar
Thu, 22 Jul 2004 14:29:20 +0000
changeset 730 af375858f17c
parent 542 69bde1d90c04
child 774 4297098d9677
permissions -rw-r--r--
Custom made INSTALL file (will be sometime).
ladanyi@542
     1
#include <hugo/xy.h>
athos@201
     2
#include <iostream>
alpar@727
     3
#include "test_tools.h"
alpar@727
     4
athos@201
     5
using namespace std;
athos@207
     6
using namespace hugo;
athos@201
     7
int main()
athos@201
     8
{
athos@207
     9
athos@518
    10
  cout << "Testing classes xy and boundingbox." << endl;
athos@201
    11
athos@513
    12
	typedef xy<int> XY;
athos@513
    13
	
athos@513
    14
	XY seged;
athos@513
    15
	XY a(1,2);
athos@513
    16
	XY b(3,4);
athos@201
    17
athos@513
    18
	seged = a+b;
alpar@727
    19
	check(seged.x==4 && seged.y==6, "Wrong vector addition");
athos@201
    20
athos@513
    21
	seged = a-b;
athos@516
    22
	check(seged.x==-2 && seged.y==-2, "a-b");
athos@513
    23
alpar@727
    24
	check(a.normSquare()==5,"Wrong norm calculation");
athos@516
    25
	check(a*b==11, "a*b");
athos@513
    26
athos@513
    27
	int l=2;
athos@513
    28
	seged = a*l;
athos@516
    29
	check(seged.x==2 && seged.y==4, "a*l");
athos@513
    30
athos@513
    31
	seged = b/l;
athos@516
    32
	check(seged.x==1 && seged.y==2, "b/l");
athos@513
    33
athos@513
    34
	typedef BoundingBox<int> BB;
athos@513
    35
	BB doboz1;
athos@516
    36
	check(doboz1.empty(), "empty? Should be.");
athos@516
    37
	
athos@513
    38
	doboz1 += a;
athos@516
    39
	check(!doboz1.empty(), "empty? Should not be.");
athos@513
    40
	doboz1 += b;
athos@513
    41
athos@516
    42
	check(doboz1.bottomLeft().x==1 && 
athos@516
    43
	      doboz1.bottomLeft().y==2 &&
athos@516
    44
	      doboz1.topRight().x==3 && 
athos@516
    45
	      doboz1.topRight().y==4,  
athos@516
    46
	      "added points to box");
athos@516
    47
athos@516
    48
	seged.x=2;seged.y=3;
alpar@727
    49
	check(doboz1.inside(seged),"Inside? It should be.");
athos@516
    50
athos@516
    51
	seged.x=1;seged.y=3;
alpar@727
    52
	check(doboz1.inside(seged),"Inside? It should be.");
athos@516
    53
athos@516
    54
	seged.x=0;seged.y=3;
alpar@727
    55
	check(!doboz1.inside(seged),"Inside? It should not be.");
athos@516
    56
athos@516
    57
	BB doboz2(seged);
alpar@727
    58
	check(!doboz2.empty(),
alpar@727
    59
	      "empty? Should not be. Constructed from 1 point.");
athos@516
    60
athos@516
    61
	doboz2 += doboz1;
alpar@727
    62
	check(doboz2.inside(seged),
alpar@727
    63
	      "Not inside? It should be. Incremented a box with an other.");
athos@201
    64
}