Changeset 369:dc9c19f4ca9a in lemon0.x for src/work/klao/path_test.cc
 Timestamp:
 04/22/04 01:47:01 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@497
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/klao/path_test.cc
r227 r369 44 44 bool rc; 45 45 46 cout << "Ures path letrehozasa" << endl; 47 typedef Path<ListGraph> LPath; 48 LPath P(G); 49 50 cout << "P.length() == " << P.length() << endl; 51 check(P.length() == 0); 52 53 cout << "P.from() valid? " << G.valid(P.from()) << endl; 54 check(! G.valid(P.from())); 55 56 cout << "Hozzaadunk ket elet..." << endl; 57 check(P.pushBack(e1)); 58 check(P.pushBack(e3)); 59 cout << "P.length() == " << P.length() << endl; 60 check(P.length() == 2); 61 62 cout << "P.from() valid? " << G.valid(P.from()) << endl; 63 check(G.valid(P.from())); 46 { 47 cout << "DynamicPath tesztelese...\n"; 48 49 cout << "Ures path letrehozasa" << endl; 50 typedef DynamicPath<ListGraph> LPath; 51 LPath P(G); 52 53 cout << "P.length() == " << P.length() << endl; 54 check(P.length() == 0); 55 56 cout << "P.from() valid? " << G.valid(P.from()) << endl; 57 check(! G.valid(P.from())); 58 59 cout << "Hozzaadunk ket elet..." << endl; 60 check(P.pushBack(e1)); 61 check(P.pushBack(e3)); 62 cout << "P.length() == " << P.length() << endl; 63 check(P.length() == 2); 64 65 cout << "P.from() valid? " << G.valid(P.from()) << endl; 66 check(G.valid(P.from())); 64 67 65 cout << "P.from()==s ? " << (P.from()==s) << endl; 66 check(P.from() == s); 67 68 cout << "Hozzaadunk egy nem illeszkedo elt." << endl; 69 rc = P.pushBack(e8); 70 cout << "Sukerult: " << rc << endl; 71 check(!rc); 72 73 cout << "Meg 3 el hozzaadasa, nem mind elore iranyu..." << endl; 74 check(P.pushBack(e6)); 75 check(P.pushBack(e8)); 76 check(P.pushBack(e10)); 77 78 cout << "P.length() == " << P.length() << endl; 79 check(P.length() == 5); 80 81 cout << "P.from()==s ? " << (P.from()==s) << endl; 82 check(P.from() == s); 83 cout << "P.to()==t ? " << (P.to()==t) << endl; 84 check(P.to() == t); 85 86 cout << "Vegpont bellitasa: " << endl; 87 rc = P.setTo(v2); 88 cout << "Hibasra: " << rc << endl; 89 check(!rc); 90 rc = P.setTo(t); 91 cout << "Helyesre: " << rc << endl; 92 check(rc); 93 94 cout << "Elek iranyitasanak ellenorzese." << endl; 95 cout << "El: " << e1 << ", G.tail(el): " << G.head(e1) << endl; 96 check(G.tail(e1)==s); 97 98 cout << "Vegigiteralunk az eleken." << endl; 99 typedef LPath::NodeIt NodeIt; 100 typedef LPath::EdgeIt EdgeIt; 101 EdgeIt e = P.first<EdgeIt>(); 102 int i=1; 103 for(; P.valid(e); P.next(e), ++i) { 104 cout << i << ". el: " << P.graphEdge(e) 105 << ", elore el? " << P.isForward(e) << endl; 106 if(i>=3 && i<5) 107 check(!P.isForward(e)); 108 else 109 check(P.isForward(e)); 68 cout << "P.from()==s ? " << (P.from()==s) << endl; 69 check(P.from() == s); 70 71 cout << "Hozzaadunk egy nem illeszkedo elt." << endl; 72 rc = P.pushBack(e8); 73 cout << "Sukerult: " << rc << endl; 74 check(!rc); 75 76 cout << "Meg 3 el hozzaadasa, nem mind elore iranyu..." << endl; 77 check(P.pushBack(e6)); 78 check(P.pushBack(e8)); 79 check(P.pushBack(e10)); 80 81 cout << "P.length() == " << P.length() << endl; 82 check(P.length() == 5); 83 84 cout << "P.from()==s ? " << (P.from()==s) << endl; 85 check(P.from() == s); 86 cout << "P.to()==t ? " << (P.to()==t) << endl; 87 check(P.to() == t); 88 89 cout << "Vegpont bellitasa: " << endl; 90 rc = P.setTo(v2); 91 cout << "Hibasra: " << rc << endl; 92 check(!rc); 93 rc = P.setTo(t); 94 cout << "Helyesre: " << rc << endl; 95 check(rc); 96 97 cout << "Elek iranyitasanak ellenorzese." << endl; 98 cout << "El: " << e1 << ", G.tail(el): " << G.head(e1) << endl; 99 check(G.tail(e1)==s); 100 101 cout << "Vegigiteralunk az eleken." << endl; 102 typedef LPath::NodeIt NodeIt; 103 typedef LPath::EdgeIt EdgeIt; 104 EdgeIt e = P.first<EdgeIt>(); 105 int i=1; 106 for(; P.valid(e); P.next(e), ++i) { 107 cout << i << ". el: " << P.graphEdge(e) 108 << ", elore el? " << P.isForward(e) << endl; 109 if(i>=3 && i<5) 110 check(!P.isForward(e)); 111 else 112 check(P.isForward(e)); 113 } 114 115 { 116 cout << "Reszut letrehozasa: [2. el, 4. el)..." << endl; 117 LPath P2(P, P.nth<EdgeIt>(1), P.nth<EdgeIt>(3)); 118 119 cout << "P2.length() == " << P2.length() << endl; 120 check(P2.length() == 2); 121 122 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl; 123 check(P2.from() == v1); 124 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl; 125 check(P2.to() == v3); 126 } 127 { 128 cout << "Reszut letrehozasa: [1. el, 6. el)..." << endl; 129 LPath P2(P, P.nth<EdgeIt>(0), P.nth<EdgeIt>(5)); 130 131 cout << "P2.length() == " << P2.length() << endl; 132 check(P2.length() == 5); 133 134 cout << "P2.from()==s ? " << (P2.from()==s) << endl; 135 check(P2.from() == s); 136 cout << "P2.to()==t ? " << (P2.to()==t) << endl; 137 check(P2.to() == t); 138 } 139 140 { 141 cout << "Ket pont altal megadott reszut letrehozasa: [2. pont, 4. pont]..." 142 << endl; 143 LPath P2(P, P.nth<NodeIt>(1), P.nth<NodeIt>(3)); 144 145 cout << "P2.length() == " << P2.length() << endl; 146 check(P2.length() == 2); 147 148 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl; 149 check(P2.from() == v1); 150 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl; 151 check(P2.to() == v3); 152 } 153 { 154 cout << "Egy pontu reszut letrehozasa: [4. pont, 4. pont]..." 155 << endl; 156 LPath P2(P, P.nth<NodeIt>(3), P.nth<NodeIt>(3)); 157 158 cout << "P2.length() == " << P2.length() << endl; 159 check(P2.length() == 0); 160 161 cout << "P2.from()==v3 ? " << (P2.from()==v3) << endl; 162 check(P2.from() == v3); 163 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl; 164 check(P2.to() == v3); 165 } 166 { 167 cout << "Forditott ut letrehozasa: [6. pont, 1. pont]..." 168 << endl; 169 LPath P2(P, P.nth<NodeIt>(5), P.nth<NodeIt>(0)); 170 171 cout << "P2.length() == " << P2.length() << endl; 172 check(P2.length() == 5); 173 174 cout << "P2.from()==t ? " << (P2.from()==t) << endl; 175 check(P2.from() == t); 176 cout << "P2.to()==s ? " << (P2.to()==s) << endl; 177 check(P2.to() == s); 178 } 179 110 180 } 111 181 112 182 { 113 cout << "Reszut letrehozasa: [2. el, 4. el)..." << endl; 114 LPath P2(P, P.nth<EdgeIt>(1), P.nth<EdgeIt>(3)); 115 116 cout << "P2.length() == " << P2.length() << endl; 117 check(P2.length() == 2); 118 119 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl; 120 check(P2.from() == v1); 121 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl; 122 check(P2.to() == v3); 183 cout << "\n\n\nDirPath tesztelese...\n"; 184 185 186 cout << "Ures path letrehozasa" << endl; 187 typedef DirPath<ListGraph> DPath; 188 DPath P(G); 189 190 cout << "P.length() == " << P.length() << endl; 191 check(P.length() == 0); 192 193 cout << "P.from() valid? " << G.valid(P.from()) << endl; 194 check(! G.valid(P.from())); 195 196 { 197 cout << "Builder objektum letrehozasa" << endl; 198 DPath::Builder B(P); 199 200 cout << "Hozzaadunk az elejehez ket elet..." << endl; 201 check(B.pushFront(e6)); 202 check(B.pushFront(e5)); 203 cout << "P.length() == " << P.length() << endl; 204 check(P.length() == 0); 205 206 cout << "Commitolunk..." << endl; 207 B.commit(); 208 209 cout << "P.length() == " << P.length() << endl; 210 check(P.length() == 2); 211 cout << "P.from() valid? " << G.valid(P.from()) << endl; 212 check(G.valid(P.from())); 213 cout << "P.from()==v1 ? " << (P.from()==v1) << endl; 214 check(P.from() == v1); 215 216 cout << "Hozzaadunk az elejehez egy nem illeszkedo elet..." << endl; 217 check(!B.pushFront(e3)); 218 219 cout << "Hozzaadunk a vegehez ket elet..." << endl; 220 check(B.pushBack(e7)); 221 check(B.pushBack(e8)); 222 cout << "P.length() == " << P.length() << endl; 223 check(P.length() == 4); 224 225 cout << "Hozzaadunk az elejehez meg egy elet..." << endl; 226 check(B.pushFront(e4)); 227 cout << "P.length() == " << P.length() << endl; 228 check(P.length() == 4); 229 230 cout << "Es megvarjuk, amig megszunik a Builder...\n"; 231 } 232 cout << "P.length() == " << P.length() << endl; 233 check(P.length() == 5); 234 cout << "P.from()==v2 ? " << (P.from()==v2) << endl; 235 check(P.from() == v2); 236 237 cout << "Vegigiteralunk az eleken." << endl; 238 typedef DPath::NodeIt NodeIt; 239 typedef DPath::EdgeIt EdgeIt; 240 EdgeIt e; 241 int i=1; 242 for(P.first(e); P.valid(e); P.next(e), ++i) { 243 cout << i << ". el: " << e << endl; 244 } 123 245 } 124 {125 cout << "Reszut letrehozasa: [1. el, 6. el)..." << endl;126 LPath P2(P, P.nth<EdgeIt>(0), P.nth<EdgeIt>(5));127 128 cout << "P2.length() == " << P2.length() << endl;129 check(P2.length() == 5);130 131 cout << "P2.from()==s ? " << (P2.from()==s) << endl;132 check(P2.from() == s);133 cout << "P2.to()==t ? " << (P2.to()==t) << endl;134 check(P2.to() == t);135 }136 137 {138 cout << "Ket pont altal megadott reszut letrehozasa: [2. pont, 4. pont]..."139 << endl;140 LPath P2(P, P.nth<NodeIt>(1), P.nth<NodeIt>(3));141 142 cout << "P2.length() == " << P2.length() << endl;143 check(P2.length() == 2);144 145 cout << "P2.from()==v1 ? " << (P2.from()==v1) << endl;146 check(P2.from() == v1);147 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;148 check(P2.to() == v3);149 }150 {151 cout << "Egy pontu reszut letrehozasa: [4. pont, 4. pont]..."152 << endl;153 LPath P2(P, P.nth<NodeIt>(3), P.nth<NodeIt>(3));154 155 cout << "P2.length() == " << P2.length() << endl;156 check(P2.length() == 0);157 158 cout << "P2.from()==v3 ? " << (P2.from()==v3) << endl;159 check(P2.from() == v3);160 cout << "P2.to()==v3 ? " << (P2.to()==v3) << endl;161 check(P2.to() == v3);162 }163 {164 cout << "Forditott ut letrehozasa: [6. pont, 1. pont]..."165 << endl;166 LPath P2(P, P.nth<NodeIt>(5), P.nth<NodeIt>(0));167 168 cout << "P2.length() == " << P2.length() << endl;169 check(P2.length() == 5);170 171 cout << "P2.from()==t ? " << (P2.from()==t) << endl;172 check(P2.from() == t);173 cout << "P2.to()==s ? " << (P2.to()==s) << endl;174 check(P2.to() == s);175 }176 177 246 178 247 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
Note: See TracChangeset
for help on using the changeset viewer.