COIN-OR::LEMON - Graph Library

Changeset 2212:0ad3835449f8 in lemon-0.x for test/dim_test.cc


Ignore:
Timestamp:
09/08/06 10:55:07 (13 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2940
Message:

Some small improvments

size() and subscription operators
compatibility with higher dimensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/dim_test.cc

    r2207 r2212  
    3030  typedef dim2::Point<int> Point;
    3131       
    32         Point seged;
    33         Point a(1,2);
    34         Point b(3,4);
     32  Point seged;
     33  check(seged.size()==2, "Wrong vector addition");
    3534
    36         seged = a+b;
    37         check(seged.x==4 && seged.y==6, "Wrong vector addition");
     35  Point a(1,2);
     36  Point b(3,4);
    3837
    39         seged = a-b;
    40         check(seged.x==-2 && seged.y==-2, "a-b");
     38  check(a[0]==1 && a[1]==2, "Wrong vector addition");
    4139
    42         check(a.normSquare()==5,"Wrong norm calculation");
    43         check(a*b==11, "a*b");
     40  seged = a+b;
     41  check(seged.x==4 && seged.y==6, "Wrong vector addition");
    4442
    45         int l=2;
    46         seged = a*l;
    47         check(seged.x==2 && seged.y==4, "a*l");
     43  seged = a-b;
     44  check(seged.x==-2 && seged.y==-2, "a-b");
    4845
    49         seged = b/l;
    50         check(seged.x==1 && seged.y==2, "b/l");
     46  check(a.normSquare()==5,"Wrong norm calculation");
     47  check(a*b==11, "a*b");
    5148
    52         typedef dim2::BoundingBox<int> BB;
    53         BB doboz1;
    54         check(doboz1.empty(), "It should be empty.");
     49  int l=2;
     50  seged = a*l;
     51  check(seged.x==2 && seged.y==4, "a*l");
     52
     53  seged = b/l;
     54  check(seged.x==1 && seged.y==2, "b/l");
     55
     56  typedef dim2::BoundingBox<int> BB;
     57  BB doboz1;
     58  check(doboz1.empty(), "It should be empty.");
    5559       
    56         doboz1.add(a);
    57         check(!doboz1.empty(), "It should not be empty.");
    58         doboz1.add(b);
     60  doboz1.add(a);
     61  check(!doboz1.empty(), "It should not be empty.");
     62  doboz1.add(b);
    5963
    60         check(doboz1.bottomLeft().x==1 &&
    61               doboz1.bottomLeft().y==2 &&
    62               doboz1.topRight().x==3 &&
    63               doboz1.topRight().y==4, 
    64               "added points to box");
     64  check(doboz1.bottomLeft().x==1 &&
     65        doboz1.bottomLeft().y==2 &&
     66        doboz1.topRight().x==3 &&
     67        doboz1.topRight().y==4, 
     68        "added points to box");
    6569
    66         seged.x=2;seged.y=3;
    67         check(doboz1.inside(seged),"It should be inside.");
     70  seged.x=2;seged.y=3;
     71  check(doboz1.inside(seged),"It should be inside.");
    6872
    69         seged.x=1;seged.y=3;
    70         check(doboz1.inside(seged),"It should be inside.");
     73  seged.x=1;seged.y=3;
     74  check(doboz1.inside(seged),"It should be inside.");
    7175
    72         seged.x=0;seged.y=3;
    73         check(!doboz1.inside(seged),"It should not be inside.");
     76  seged.x=0;seged.y=3;
     77  check(!doboz1.inside(seged),"It should not be inside.");
    7478
    75         BB doboz2(seged);
    76         check(!doboz2.empty(),
    77               "It should not be empty. Constructed from 1 point.");
     79  BB doboz2(seged);
     80  check(!doboz2.empty(),
     81        "It should not be empty. Constructed from 1 point.");
    7882
    79         doboz2.add(doboz1);
    80         check(doboz2.inside(seged),
    81               "It should be inside. Incremented a box with another one.");
     83  doboz2.add(doboz1);
     84  check(doboz2.inside(seged),
     85        "It should be inside. Incremented a box with another one.");
    8286}
Note: See TracChangeset for help on using the changeset viewer.