Rev | Line | |
---|

[542] | 1 | #include <hugo/xy.h> |
---|

[201] | 2 | #include <iostream> |
---|

[727] | 3 | #include "test_tools.h" |
---|

| 4 | |
---|

[201] | 5 | using namespace std; |
---|

[207] | 6 | using namespace hugo; |
---|

[201] | 7 | int main() |
---|

| 8 | { |
---|

[207] | 9 | |
---|

[774] | 10 | cout << "Testing classes `xy' and `boundingbox'." << endl; |
---|

[201] | 11 | |
---|

[513] | 12 | typedef xy<int> XY; |
---|

| 13 | |
---|

| 14 | XY seged; |
---|

| 15 | XY a(1,2); |
---|

| 16 | XY b(3,4); |
---|

[201] | 17 | |
---|

[513] | 18 | seged = a+b; |
---|

[727] | 19 | check(seged.x==4 && seged.y==6, "Wrong vector addition"); |
---|

[201] | 20 | |
---|

[513] | 21 | seged = a-b; |
---|

[516] | 22 | check(seged.x==-2 && seged.y==-2, "a-b"); |
---|

[513] | 23 | |
---|

[727] | 24 | check(a.normSquare()==5,"Wrong norm calculation"); |
---|

[516] | 25 | check(a*b==11, "a*b"); |
---|

[513] | 26 | |
---|

| 27 | int l=2; |
---|

| 28 | seged = a*l; |
---|

[516] | 29 | check(seged.x==2 && seged.y==4, "a*l"); |
---|

[513] | 30 | |
---|

| 31 | seged = b/l; |
---|

[516] | 32 | check(seged.x==1 && seged.y==2, "b/l"); |
---|

[513] | 33 | |
---|

| 34 | typedef BoundingBox<int> BB; |
---|

| 35 | BB doboz1; |
---|

[774] | 36 | check(doboz1.empty(), "It should be empty."); |
---|

[516] | 37 | |
---|

[513] | 38 | doboz1 += a; |
---|

[774] | 39 | check(!doboz1.empty(), "It should not be empty."); |
---|

[513] | 40 | doboz1 += b; |
---|

| 41 | |
---|

[516] | 42 | check(doboz1.bottomLeft().x==1 && |
---|

| 43 | doboz1.bottomLeft().y==2 && |
---|

| 44 | doboz1.topRight().x==3 && |
---|

| 45 | doboz1.topRight().y==4, |
---|

| 46 | "added points to box"); |
---|

| 47 | |
---|

| 48 | seged.x=2;seged.y=3; |
---|

[774] | 49 | check(doboz1.inside(seged),"It should be inside."); |
---|

[516] | 50 | |
---|

| 51 | seged.x=1;seged.y=3; |
---|

[774] | 52 | check(doboz1.inside(seged),"It should be inside."); |
---|

[516] | 53 | |
---|

| 54 | seged.x=0;seged.y=3; |
---|

[774] | 55 | check(!doboz1.inside(seged),"It should not be inside."); |
---|

[516] | 56 | |
---|

| 57 | BB doboz2(seged); |
---|

[727] | 58 | check(!doboz2.empty(), |
---|

[774] | 59 | "It should not be empty. Constructed from 1 point."); |
---|

[516] | 60 | |
---|

| 61 | doboz2 += doboz1; |
---|

[727] | 62 | check(doboz2.inside(seged), |
---|

[774] | 63 | "It should be inside. Incremented a box with an other."); |
---|

[201] | 64 | } |
---|

**Note:** See

TracBrowser
for help on using the repository browser.