COIN-OR::LEMON - Graph Library

Changeset 516:c37949721c61 in lemon-0.x for src


Ignore:
Timestamp:
05/04/04 10:31:48 (20 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@678
Message:

Test file xy_test.cc finished.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • src/test/xy_test.cc

    r513 r516  
    66bool passed = true;
    77
    8 void check(bool rc) {
     8void check(bool rc, char *msg="") {
    99  passed = passed && rc;
    1010  if(!rc) {
    11     cout << "Test failed!" << endl;
     11    std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
     12 
     13
    1214  }
    1315}
     
    3032
    3133        seged = a-b;
    32         check(seged.x==-1 && seged.y==-1);
     34        check(seged.x==-2 && seged.y==-2, "a-b");
    3335
    3436        check(a.normSquare()==5);
    35         check(a*b==11);
     37        check(a*b==11, "a*b");
    3638
    3739        int l=2;
    3840        seged = a*l;
    39         check(seged.x==2 && seged.y==4);
     41        check(seged.x==2 && seged.y==4, "a*l");
    4042
    4143        seged = b/l;
    42         check(seged.x==1 && seged.y==2);
     44        check(seged.x==1 && seged.y==2, "b/l");
    4345
    4446        typedef BoundingBox<int> BB;
    4547        BB doboz1;
     48        check(doboz1.empty(), "empty? Should be.");
     49       
    4650        doboz1 += a;
     51        check(!doboz1.empty(), "empty? Should not be.");
    4752        doboz1 += b;
     53
     54        check(doboz1.bottomLeft().x==1 &&
     55              doboz1.bottomLeft().y==2 &&
     56              doboz1.topRight().x==3 &&
     57              doboz1.topRight().y==4, 
     58              "added points to box");
     59
     60        seged.x=2;seged.y=3;
     61        check(doboz1.inside(seged),"Inside? Should be.");
     62
     63        seged.x=1;seged.y=3;
     64        check(doboz1.inside(seged),"Inside? Should be.");
     65
     66        seged.x=0;seged.y=3;
     67        check(!doboz1.inside(seged),"Inside? Should not be.");
     68
     69        BB doboz2(seged);
     70        check(!doboz2.empty(), "empty? Should not be.");
     71
     72        doboz2 += doboz1;
     73        check(doboz2.inside(seged),"Inside? Should be.");
    4874
    4975        cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
Note: See TracChangeset for help on using the changeset viewer.