hegyi@820: #include hegyi@820: #include hegyi@820: //#include hegyi@820: #include hegyi@820: #include hegyi@820: hegyi@820: using namespace std; hegyi@820: using namespace hugo; hegyi@820: #ifdef SKELETON hegyi@820: using namespace skeleton; hegyi@820: #endif hegyi@820: hegyi@820: bool passed = true; hegyi@820: hegyi@820: void check(bool rc) { hegyi@820: passed = passed && rc; hegyi@820: if(!rc) { hegyi@820: cout << "Test failed!" << endl; hegyi@820: } hegyi@820: } hegyi@820: hegyi@820: #ifdef DEBUG hegyi@820: const bool debug = true; hegyi@820: #else hegyi@820: const bool debug = false; hegyi@820: #endif hegyi@820: hegyi@820: hegyi@820: int main() { hegyi@820: hegyi@820: try { hegyi@820: hegyi@820: typedef ListGraph::Node Node; hegyi@820: typedef ListGraph::Edge Edge; hegyi@820: hegyi@820: ListGraph G; hegyi@820: hegyi@820: Node s=G.addNode(); hegyi@820: Node v1=G.addNode(); hegyi@820: Node v2=G.addNode(); hegyi@820: Node v3=G.addNode(); hegyi@820: Node v4=G.addNode(); hegyi@820: Node t=G.addNode(); hegyi@820: hegyi@820: Edge e1 = G.addEdge(s, v1); hegyi@820: Edge e2 = G.addEdge(s, v2); hegyi@820: Edge e3 = G.addEdge(v1, v2); hegyi@820: Edge e4 = G.addEdge(v2, v1); hegyi@820: Edge e5 = G.addEdge(v1, v3); hegyi@820: Edge e6 = G.addEdge(v3, v2); hegyi@820: Edge e7 = G.addEdge(v2, v4); hegyi@820: Edge e8 = G.addEdge(v4, v3); hegyi@820: Edge e9 = G.addEdge(v3, t); hegyi@820: Edge e10 = G.addEdge(v4, t); hegyi@820: hegyi@820: #ifdef DEBUG hegyi@820: bool rc; hegyi@820: #endif hegyi@820: hegyi@820: { hegyi@820: cout << "\n\n\nDirPath tesztelese...\n"; hegyi@820: hegyi@820: hegyi@820: cout << "Ures path letrehozasa" << endl; hegyi@820: #ifdef SKELETON hegyi@820: typedef Path DPath; hegyi@820: #else hegyi@820: typedef DirPath DPath; hegyi@820: #endif hegyi@820: DPath P(G); hegyi@820: hegyi@820: cout << "P.length() == " << P.length() << endl; hegyi@820: check(P.length() == 0); hegyi@820: hegyi@820: #ifdef SKELETON hegyi@820: cout << "P.tail() valid? " << (P.tail()!=INVALID) << endl; hegyi@820: check(! (P.tail()!=INVALID)); hegyi@820: #else hegyi@820: cout << "P.tail() valid? " << (P.from()!=INVALID) << endl; hegyi@820: check(! (P.to()!=INVALID)); hegyi@820: #endif hegyi@820: { hegyi@820: cout << "Builder objektum letrehozasa" << endl; hegyi@820: DPath::Builder B(P); hegyi@820: hegyi@820: cout << "Hozzaadunk az elejehez ket elet..." << endl; hegyi@820: B.pushFront(e6); hegyi@820: B.pushFront(e5); hegyi@820: cout << "P.length() == " << P.length() << endl; hegyi@820: check(P.length() == 0); hegyi@820: hegyi@820: cout << "Commitolunk..." << endl; hegyi@820: B.commit(); hegyi@820: hegyi@820: cout << "P.length() == " << P.length() << endl; hegyi@820: check(P.length() == 2); hegyi@820: hegyi@820: #ifdef SKELETON hegyi@820: cout << "P.tail() valid? " << (P.tail()!=INVALID) << endl; hegyi@820: check(P.tail()!=INVALID); hegyi@820: cout << "P.tail()==v1 ? " << (P.tail()==v1) << endl; hegyi@820: check(P.tail() == v1); hegyi@820: #else hegyi@820: cout << "P.tail() valid? " << (P.from()!=INVALID) << endl; hegyi@820: check(P.from()!=INVALID); hegyi@820: cout << "P.tail()==v1 ? " << (P.from()==v1) << endl; hegyi@820: check(P.from() == v1); hegyi@820: #endif hegyi@820: hegyi@820: // Na ja, ez igy nem igazi, mindket esetet le kene tesztelni, hegyi@820: // de legalabb valami: hegyi@820: #ifdef DEBUG hegyi@820: cout << "Hozzaadunk az elejehez egy nem illeszkedo elet..." << endl; hegyi@820: rc = false; hegyi@820: try { hegyi@820: B.pushFront(e3); hegyi@820: } hegyi@820: catch(const Exception &e) { hegyi@820: cout << "E: " << e.what() << endl; hegyi@820: rc = true; hegyi@820: } hegyi@820: check(rc); hegyi@820: #endif hegyi@820: hegyi@820: cout << "Hozzaadunk a vegehez ket elet..." << endl; hegyi@820: B.pushBack(e7); hegyi@820: B.pushBack(e8); hegyi@820: cout << "P.length() == " << P.length() << endl; hegyi@820: check(P.length() == 2); hegyi@820: hegyi@820: cout << "Es commitolunk...\n"; hegyi@820: B.commit(); hegyi@820: } hegyi@820: cout << "P.length() == " << P.length() << endl; hegyi@820: check(P.length() == 4); hegyi@820: hegyi@820: #ifdef SKELETON hegyi@820: cout << "P.head()==v3 ? " << (P.head()==v3) << endl; hegyi@820: check(P.head() == v3); hegyi@820: #else hegyi@820: cout << "P.head()==v3 ? " << (P.to()==v3) << endl; hegyi@820: check(P.to() == v3); hegyi@820: #endif hegyi@820: hegyi@820: cout << "Vegigiteralunk az eleken." << endl; hegyi@820: typedef DPath::NodeIt NodeIt; hegyi@820: typedef DPath::EdgeIt EdgeIt; hegyi@820: EdgeIt e; hegyi@820: int i=1; hegyi@820: for(P.first(e); e!=INVALID; ++e, ++i) { hegyi@820: cout << i << ". el: " <