Rev | Line | |
---|
[201] | 1 | #include <xy.h> |
---|
| 2 | #include <iostream> |
---|
| 3 | using namespace std; |
---|
[207] | 4 | using namespace hugo; |
---|
[513] | 5 | |
---|
| 6 | bool passed = true; |
---|
| 7 | |
---|
| 8 | void check(bool rc) { |
---|
| 9 | passed = passed && rc; |
---|
| 10 | if(!rc) { |
---|
| 11 | cout << "Test failed!" << endl; |
---|
| 12 | } |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | |
---|
[201] | 17 | int main() |
---|
| 18 | { |
---|
[207] | 19 | |
---|
| 20 | |
---|
[201] | 21 | |
---|
[513] | 22 | typedef xy<int> XY; |
---|
| 23 | |
---|
| 24 | XY seged; |
---|
| 25 | XY a(1,2); |
---|
| 26 | XY b(3,4); |
---|
[201] | 27 | |
---|
[513] | 28 | seged = a+b; |
---|
| 29 | check(seged.x==4 && seged.y==6); |
---|
[201] | 30 | |
---|
[513] | 31 | seged = a-b; |
---|
| 32 | check(seged.x==-1 && seged.y==-1); |
---|
| 33 | |
---|
| 34 | check(a.normSquare()==5); |
---|
| 35 | check(a*b==11); |
---|
| 36 | |
---|
| 37 | int l=2; |
---|
| 38 | seged = a*l; |
---|
| 39 | check(seged.x==2 && seged.y==4); |
---|
| 40 | |
---|
| 41 | seged = b/l; |
---|
| 42 | check(seged.x==1 && seged.y==2); |
---|
| 43 | |
---|
| 44 | typedef BoundingBox<int> BB; |
---|
| 45 | BB doboz1; |
---|
| 46 | doboz1 += a; |
---|
| 47 | doboz1 += b; |
---|
| 48 | |
---|
| 49 | cout << (passed ? "All tests passed." : "Some of the tests failed!!!") |
---|
| 50 | << endl; |
---|
| 51 | |
---|
| 52 | return passed ? 0 : 1; |
---|
| 53 | |
---|
[201] | 54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.