src/test/xy_test.cc
author hegyi
Tue, 07 Sep 2004 13:55:35 +0000
changeset 815 468c9ec86928
parent 727 aada518af30f
child 906 17f31d280385
permissions -rw-r--r--
(none)
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
alpar@774
    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;
alpar@774
    36
	check(doboz1.empty(), "It should be empty.");
athos@516
    37
	
athos@513
    38
	doboz1 += a;
alpar@774
    39
	check(!doboz1.empty(), "It should not be empty.");
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@774
    49
	check(doboz1.inside(seged),"It should be inside.");
athos@516
    50
athos@516
    51
	seged.x=1;seged.y=3;
alpar@774
    52
	check(doboz1.inside(seged),"It should be inside.");
athos@516
    53
athos@516
    54
	seged.x=0;seged.y=3;
alpar@774
    55
	check(!doboz1.inside(seged),"It should not be inside.");
athos@516
    56
athos@516
    57
	BB doboz2(seged);
alpar@727
    58
	check(!doboz2.empty(),
alpar@774
    59
	      "It should not be empty. Constructed from 1 point.");
athos@516
    60
athos@516
    61
	doboz2 += doboz1;
alpar@727
    62
	check(doboz2.inside(seged),
alpar@774
    63
	      "It should be inside. Incremented a box with an other.");
athos@201
    64
}