src/work/athos/xy/xy_test.cc
author athos
Mon, 03 May 2004 14:43:49 +0000
changeset 514 fd991a24c857
parent 240 4a1d2e642552
permissions -rw-r--r--
An awful mistake found and corrected.
athos@201
     1
#include <xy.h>
athos@201
     2
#include <iostream>
athos@201
     3
using namespace std;
athos@207
     4
using namespace hugo;
athos@513
     5
athos@513
     6
bool passed = true;
athos@513
     7
athos@513
     8
void check(bool rc) {
athos@513
     9
  passed = passed && rc;
athos@513
    10
  if(!rc) {
athos@513
    11
    cout << "Test failed!" << endl;
athos@513
    12
  }
athos@513
    13
}
athos@513
    14
athos@513
    15
athos@513
    16
athos@201
    17
int main()
athos@201
    18
{
athos@207
    19
athos@207
    20
athos@201
    21
athos@513
    22
	typedef xy<int> XY;
athos@513
    23
	
athos@513
    24
	XY seged;
athos@513
    25
	XY a(1,2);
athos@513
    26
	XY b(3,4);
athos@201
    27
athos@513
    28
	seged = a+b;
athos@513
    29
	check(seged.x==4 && seged.y==6);
athos@201
    30
athos@513
    31
	seged = a-b;
athos@513
    32
	check(seged.x==-1 && seged.y==-1);
athos@513
    33
athos@513
    34
	check(a.normSquare()==5);
athos@513
    35
	check(a*b==11);
athos@513
    36
athos@513
    37
	int l=2;
athos@513
    38
	seged = a*l;
athos@513
    39
	check(seged.x==2 && seged.y==4);
athos@513
    40
athos@513
    41
	seged = b/l;
athos@513
    42
	check(seged.x==1 && seged.y==2);
athos@513
    43
athos@513
    44
	typedef BoundingBox<int> BB;
athos@513
    45
	BB doboz1;
athos@513
    46
	doboz1 += a;
athos@513
    47
	doboz1 += b;
athos@513
    48
athos@513
    49
	cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
athos@513
    50
	     << endl;
athos@513
    51
athos@513
    52
	return passed ? 0 : 1;
athos@513
    53
athos@201
    54
}