diff -r 9c472eee236f -r 269a0dcee70b test/path_test.cc --- a/test/path_test.cc Tue Oct 17 10:42:19 2006 +0000 +++ b/test/path_test.cc Tue Oct 17 10:50:57 2006 +0000 @@ -18,81 +18,91 @@ #include #include + #include +#include + #include #include +#include "test_tools.h" + using namespace std; using namespace lemon; -using namespace lemon::concept; -template void checkCompilePath(Path &P) -{ - typedef typename Path::EdgeIt EdgeIt; - typedef typename Path::NodeIt NodeIt; - typedef typename Path::GraphNode GraphNode; - typedef typename Path::GraphEdge GraphEdge; - //typedef typename Path::Builder Builder; - //??? ha csinalok ilyet es siman Builderrel peldanyositok, akkor warningol. Talan friend miatt? De ki az? - - EdgeIt ei; - NodeIt ni; - GraphNode gn; - GraphEdge ge; - - size_t st; - bool b; - - //Path(const Graph &_G) {} //the constructor has been already called - - st=P.length(); //size_t length() const {return 0;} - b=P.empty(); //bool empty() const {} - P.clear(); //void clear() {} - - gn=P.target(); //GraphNode/*It*/ target() const {return INVALID;} - gn=P.source(); //GraphNode/*It*/ source() const {return INVALID;} - - ei=P.first(ei); //It& first(It &i) const { return i=It(*this); } - - ni=P.target(ei); //NodeIt target(const EdgeIt& e) const {} - ni=P.source(ei); //NodeIt source(const EdgeIt& e) const {} - - - ListGraph lg; - Path p(lg); - - EdgeIt i; //EdgeIt() {} - EdgeIt j(INVALID); //EdgeIt(Invalid) {} - EdgeIt k(p); //EdgeIt(const Path &_p) {} - - i=++j; //EdgeIt& operator++() {} - ++k; - b=(i==j); //bool operator==(const EdgeIt& e) const {return true;} - b=(i!=j); //bool operator!=(const EdgeIt& e) const {return true;} - - - NodeIt l; //NodeIt() {} - NodeIt m(INVALID); //NodeIt(Invalid) {} - NodeIt n(p); //NodeIt(const Path &_p) {} - - l=++m; //NodeIt& operator++() {} - b=(m==n); //bool operator==(const NodeIt& e) const {} - b=(m!=n); //bool operator!=(const NodeIt& e) const {} - - typename Path::Builder builder(p); //Builder(Path &_P) : P(_P) {} - builder.setStartNode(gn); //void setStartNode(const GraphNode &) {} - builder.pushFront(ge); //void pushFront(const GraphEdge& e) {} - builder.pushBack(ge); //void pushBack(const GraphEdge& e) {} - builder.commit(); //void commit() {} - builder.reserveFront(st); //void reserveFront(size_t r) {} - builder.reserveBack(st); //void reserveBack(size_t r) {} - +void check_concepts() { + checkConcept, + concept::Path >(); + checkConcept, + Path >(); + checkConcept, Path >(); } -template void checkCompilePath< concept::Path >(concept::Path &); -template void checkCompilePath< DirPath >(DirPath &); -template void checkCompilePath< UPath >(UPath &); +int main() { + check_concepts(); + + ListGraph g; + + ListGraph::Node n1 = g.addNode(); + ListGraph::Node n2 = g.addNode(); + ListGraph::Node n3 = g.addNode(); + ListGraph::Node n4 = g.addNode(); + ListGraph::Node n5 = g.addNode(); + + ListGraph::Edge e1 = g.addEdge(n1, n2); + ListGraph::Edge e2 = g.addEdge(n2, n3); + ListGraph::Edge e3 = g.addEdge(n3, n4); + ListGraph::Edge e4 = g.addEdge(n4, n5); + ListGraph::Edge e5 = g.addEdge(n5, n1); -int main() -{ + { + Path p(g); + + check(p.empty(), "Wrong Path"); + check(p.length() == 0, "Wrong Path"); + + { + Path::Builder b(p); + b.setStartNode(n3); + b.commit(); + } + + check(!p.empty(), "Wrong Path"); + check(p.length() == 0, "Wrong Path"); + check(p.source() == n3, "Wrong Path"); + check(p.target() == n3, "Wrong Path"); + + { + Path::Builder b(p); + b.pushBack(e3); + b.pushBack(e4); + b.pushFront(e2); + b.commit(); + } + + check(!p.empty(), "Wrong Path"); + check(p.length() == 3, "Wrong Path"); + check(p.source() == n2, "Wrong Path"); + check(p.target() == n5, "Wrong Path"); + + { + Path::NodeIt it(p); + check((ListGraph::Node)it == n2, "Wrong Path"); ++it; + check((ListGraph::Node)it == n3, "Wrong Path"); ++it; + check((ListGraph::Node)it == n4, "Wrong Path"); ++it; + check((ListGraph::Node)it == n5, "Wrong Path"); ++it; + check((ListGraph::Node)it == INVALID, "Wrong Path"); + } + + { + Path::EdgeIt it(p); + check((ListGraph::Edge)it == e2, "Wrong Path"); ++it; + check((ListGraph::Edge)it == e3, "Wrong Path"); ++it; + check((ListGraph::Edge)it == e4, "Wrong Path"); ++it; + check((ListGraph::Edge)it == INVALID, "Wrong Path"); + } + + } + + return 0; }