Changeset 2212:0ad3835449f8 in lemon0.x
 Timestamp:
 09/08/06 10:55:07 (18 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2940
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

lemon/dim2.h
r2207 r2212 74 74 Point(T a, T b) : x(a), y(b) { } 75 75 76 ///Size of vector 77 int size() const { return 2; } 78 79 ///Subscripting operator 80 T& operator[](int idx) { return idx == 0 ? x : y; } 81 82 ///Const subscripting operator 83 const T& operator[](int idx) const { return idx == 0 ? x : y; } 76 84 77 85 ///Conversion constructor … … 164 172 ///\relates Point 165 173 template <typename T> 166 inline Point<T> make _Point(const T& x, const T& y) {174 inline Point<T> makePoint(const T& x, const T& y) { 167 175 return Point<T>(x, y); 168 176 } 
test/dim_test.cc
r2207 r2212 30 30 typedef dim2::Point<int> Point; 31 31 32 Point seged; 33 Point a(1,2); 34 Point b(3,4); 32 Point seged; 33 check(seged.size()==2, "Wrong vector addition"); 35 34 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); 38 37 39 seged = ab; 40 check(seged.x==2 && seged.y==2, "ab"); 38 check(a[0]==1 && a[1]==2, "Wrong vector addition"); 41 39 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"); 44 42 45 int l=2; 46 seged = a*l; 47 check(seged.x==2 && seged.y==4, "a*l"); 43 seged = ab; 44 check(seged.x==2 && seged.y==2, "ab"); 48 45 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"); 51 48 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."); 55 59 56 57 58 60 doboz1.add(a); 61 check(!doboz1.empty(), "It should not be empty."); 62 doboz1.add(b); 59 63 60 61 62 63 64 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"); 65 69 66 67 70 seged.x=2;seged.y=3; 71 check(doboz1.inside(seged),"It should be inside."); 68 72 69 70 73 seged.x=1;seged.y=3; 74 check(doboz1.inside(seged),"It should be inside."); 71 75 72 73 76 seged.x=0;seged.y=3; 77 check(!doboz1.inside(seged),"It should not be inside."); 74 78 75 76 77 79 BB doboz2(seged); 80 check(!doboz2.empty(), 81 "It should not be empty. Constructed from 1 point."); 78 82 79 80 81 83 doboz2.add(doboz1); 84 check(doboz2.inside(seged), 85 "It should be inside. Incremented a box with another one."); 82 86 }
Note: See TracChangeset
for help on using the changeset viewer.