COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/athos/xy/xy_test.cc @ 513:60afd11e6cb3

Last change on this file since 513:60afd11e6cb3 was 513:60afd11e6cb3, checked in by athos, 17 years ago

xy_test added: it was not entirely useless, I found a mistake in xy.h

File size: 719 bytes
Line 
1#include <xy.h>
2#include <iostream>
3using namespace std;
4using namespace hugo;
5
6bool passed = true;
7
8void check(bool rc) {
9  passed = passed && rc;
10  if(!rc) {
11    cout << "Test failed!" << endl;
12  }
13}
14
15
16
17int main()
18{
19
20
21
22        typedef xy<int> XY;
23       
24        XY seged;
25        XY a(1,2);
26        XY b(3,4);
27
28        seged = a+b;
29        check(seged.x==4 && seged.y==6);
30
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
54}
Note: See TracBrowser for help on using the repository browser.