The first version of new path test program. The old became old_path_test.
3 //#include <hugo/skeletons/path.h>
5 #include <hugo/list_graph.h>
9 #ifdef HUGO_SKELETON_PATH_H
10 using namespace skeleton;
16 passed = passed && rc;
18 cout << "Test failed!" << endl;
23 const bool debug = true;
25 const bool debug = false;
33 typedef ListGraph::Node Node;
34 typedef ListGraph::Edge Edge;
45 Edge e1 = G.addEdge(s, v1);
46 Edge e2 = G.addEdge(s, v2);
47 Edge e3 = G.addEdge(v1, v2);
48 Edge e4 = G.addEdge(v2, v1);
49 Edge e5 = G.addEdge(v1, v3);
50 Edge e6 = G.addEdge(v3, v2);
51 Edge e7 = G.addEdge(v2, v4);
52 Edge e8 = G.addEdge(v4, v3);
53 Edge e9 = G.addEdge(v3, t);
54 Edge e10 = G.addEdge(v4, t);
61 cout << "\n\n\nDirPath tesztelese...\n";
64 cout << "Ures path letrehozasa" << endl;
66 #ifndef HUGO_SKELETON_PATH_H
67 typedef DirPath<ListGraph> DPath;
69 typedef Path<ListGraph> DPath;
74 cout << "P.length() == " << P.length() << endl;
75 check(P.length() == 0);
77 cout << "P.tail() valid? " << (P.tail()!=INVALID) << endl;
78 check(! (P.tail()!=INVALID));
80 cout << "Builder objektum letrehozasa" << endl;
83 cout << "Hozzaadunk az elejehez ket elet..." << endl;
86 cout << "P.length() == " << P.length() << endl;
87 check(P.length() == 0);
89 cout << "Commitolunk..." << endl;
92 cout << "P.length() == " << P.length() << endl;
93 check(P.length() == 2);
95 cout << "P.tail() valid? " << (P.tail()!=INVALID) << endl;
96 check(P.tail()!=INVALID);
97 cout << "P.tail()==v1 ? " << (P.tail()==v1) << endl;
98 check(P.tail() == v1);
100 // Na ja, ez igy nem igazi, mindket esetet le kene tesztelni,
101 // de legalabb valami:
103 cout << "Hozzaadunk az elejehez egy nem illeszkedo elet..." << endl;
108 catch(const Exception &e) {
109 cout << "E: " << e.what() << endl;
115 cout << "Hozzaadunk a vegehez ket elet..." << endl;
118 cout << "P.length() == " << P.length() << endl;
119 check(P.length() == 2);
121 cout << "Es commitolunk...\n";
124 cout << "P.length() == " << P.length() << endl;
125 check(P.length() == 4);
127 cout << "P.head()==v3 ? " << (P.head()==v3) << endl;
128 check(P.head() == v3);
130 #ifndef HUGO_SKELETON_PATH_H
131 cout << "Vegigiteralunk az eleken." << endl;
132 typedef DPath::NodeIt NodeIt;
133 typedef DPath::EdgeIt EdgeIt;
136 for(P.first(e); e!=INVALID; ++e, ++i) {
137 cout << i << ". el: " <</* e << */endl;
141 // Na ja, ez igy nem igazi, mindket esetet le kene tesztelni,
142 // de legalabb valami:
147 cout << "Setting an edgeiter to a nonexistant edge." << endl;
151 catch(const Exception &e) {
152 cout << "E: " << e.what() << endl;
160 catch(const std::exception &e) {
161 cout << "Uncaught exception: " << e.what() << endl;
165 cout << "Something horrible happened: an exception which isn't "
166 << "std::exception" << endl;
171 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
174 return passed ? 0 : 1;