# HG changeset patch # User alpar # Date 1094232862 0 # Node ID b70a494b491209d8cbc03543257328c17c7e87dd # Parent 3393abe306787ab99ed4ffed5fa1e9253a72ed7e Move general graph compilation tests to 'src/test/graph_test.h'. diff -r 3393abe30678 -r b70a494b4912 src/test/Makefile.am --- a/src/test/Makefile.am Fri Sep 03 15:32:03 2004 +0000 +++ b/src/test/Makefile.am Fri Sep 03 17:34:22 2004 +0000 @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -noinst_HEADERS = test_tools.h +noinst_HEADERS = test_tools.h graph_test.h check_PROGRAMS = test_tools_pass test_tools_fail \ graph_test \ diff -r 3393abe30678 -r b70a494b4912 src/test/graph_test.cc --- a/src/test/graph_test.cc Fri Sep 03 15:32:03 2004 +0000 +++ b/src/test/graph_test.cc Fri Sep 03 17:34:22 2004 +0000 @@ -5,6 +5,7 @@ #include #include"test_tools.h" +#include"graph_test.h" /** \file @@ -13,306 +14,17 @@ G.addNode(), G.addEdge(), G.tail(), G.head() \todo Checks for empty graphs and isolated points. -\todo Checks for Node->NodeIt, Edge->{EdgeIt,InEdgeIt,OutEdgeIt} conversion. */ using namespace hugo; -template void checkCompileStaticGraph(Graph &G) -{ - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::Edge Edge; - typedef typename Graph::EdgeIt EdgeIt; - typedef typename Graph::InEdgeIt InEdgeIt; - typedef typename Graph::OutEdgeIt OutEdgeIt; - - { - Node i; Node j(i); Node k(INVALID); - i=j; - // bool b=G.valid(i); b=b; - bool b; b=b; - b=(i==INVALID); b=(i!=INVALID); - b=(i==j); b=(i!=j); b=(iNodeIt conversion - NodeIt ni(G,n); - } - { - Edge i; Edge j(i); Edge k(INVALID); - i=j; - // bool b=G.valid(i); b=b; - bool b; b=b; - b=(i==INVALID); b=(i!=INVALID); - b=(i==j); b=(i!=j); b=(iEdgeIt conversion - EdgeIt ei(G,e); - } - { - Node n; - InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n); - i=j; - j=G.first(i,n); - j=++i; - // bool b=G.valid(i); b=b; - bool b; b=b; - b=(i==INVALID); b=(i!=INVALID); - Edge e(i); - e=i; - b=(i==j); b=(i!=j); b=(iInEdgeIt conversion - InEdgeIt ei(G,e); - } - { - Node n; - OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n); - i=j; - j=G.first(i,n); - j=++i; - // bool b=G.valid(i); b=b; - bool b; b=b; - b=(i==INVALID); b=(i!=INVALID); - Edge e(i); - e=i; - b=(i==j); b=(i!=j); b=(iOutEdgeIt conversion - OutEdgeIt ei(G,e); - } - { - Node n,m; - n=m=INVALID; - Edge e; - e=INVALID; - n=G.tail(e); - n=G.head(e); - } - // id tests - { Node n; int i=G.id(n); i=i; } - { Edge e; int i=G.id(e); i=i; } - //NodeMap tests - { - Node k; - typename Graph::template NodeMap m(G); - //Const map - typename Graph::template NodeMap const &cm = m; - //Inicialize with default value - typename Graph::template NodeMap mdef(G,12); - //Copy - typename Graph::template NodeMap mm(cm); - //Copy from another type - typename Graph::template NodeMap dm(cm); - int v; - v=m[k]; m[k]=v; m.set(k,v); - v=cm[k]; - - m=cm; - dm=cm; //Copy from another type - { - //Check the typedef's - typename Graph::template NodeMap::ValueType val; - val=1; - typename Graph::template NodeMap::KeyType key; - key = typename Graph::NodeIt(G); - } - } - { //bool NodeMap - Node k; - typename Graph::template NodeMap m(G); - typename Graph::template NodeMap const &cm = m; //Const map - //Inicialize with default value - typename Graph::template NodeMap mdef(G,12); - typename Graph::template NodeMap mm(cm); //Copy - typename Graph::template NodeMap dm(cm); //Copy from another type - bool v; - v=m[k]; m[k]=v; m.set(k,v); - v=cm[k]; - - m=cm; - dm=cm; //Copy from another type - m=dm; //Copy to another type - - { - //Check the typedef's - typename Graph::template NodeMap::ValueType val; - val=true; - typename Graph::template NodeMap::KeyType key; - key= typename Graph::NodeIt(G); - } - } - //EdgeMap tests - { - Edge k; - typename Graph::template EdgeMap m(G); - typename Graph::template EdgeMap const &cm = m; //Const map - //Inicialize with default value - typename Graph::template EdgeMap mdef(G,12); - typename Graph::template EdgeMap mm(cm); //Copy - typename Graph::template EdgeMap dm(cm); //Copy from another type - int v; - v=m[k]; m[k]=v; m.set(k,v); - v=cm[k]; - - m=cm; - dm=cm; //Copy from another type - { - //Check the typedef's - typename Graph::template EdgeMap::ValueType val; - val=1; - typename Graph::template EdgeMap::KeyType key; - key= typename Graph::EdgeIt(G); - } - } - { //bool EdgeMap - Edge k; - typename Graph::template EdgeMap m(G); - typename Graph::template EdgeMap const &cm = m; //Const map - //Inicialize with default value - typename Graph::template EdgeMap mdef(G,12); - typename Graph::template EdgeMap mm(cm); //Copy - typename Graph::template EdgeMap dm(cm); //Copy from another type - bool v; - v=m[k]; m[k]=v; m.set(k,v); - v=cm[k]; - - m=cm; - dm=cm; //Copy from another type - m=dm; //Copy to another type - { - //Check the typedef's - typename Graph::template EdgeMap::ValueType val; - val=true; - typename Graph::template EdgeMap::KeyType key; - key= typename Graph::EdgeIt(G); - } - } -} - -template void checkCompile(Graph &G) -{ - checkCompileStaticGraph(G); - - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::Edge Edge; - typedef typename Graph::EdgeIt EdgeIt; - typedef typename Graph::InEdgeIt InEdgeIt; - typedef typename Graph::OutEdgeIt OutEdgeIt; - - Node n,m; - n=G.addNode(); - m=G.addNode(); - Edge e; - e=G.addEdge(n,m); - - // G.clear(); -} - -template void checkCompileErase(Graph &G) -{ - typedef typename Graph::Node Node; - typedef typename Graph::Edge Edge; - Node n; - Edge e; - G.erase(n); - G.erase(e); -} - -template void checkCompileEraseEdge(Graph &G) -{ - typedef typename Graph::Edge Edge; - Edge e; - G.erase(e); -} - -template void checkCompileFindEdge(Graph &G) -{ - typedef typename Graph::NodeIt Node; - typedef typename Graph::NodeIt NodeIt; - - G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G))); - G.findEdge(Node(),Node(),G.findEdge(Node(),Node())); -} - - -template void checkNodeList(Graph &G, int nn) -{ - typename Graph::NodeIt n(G); - for(int i=0;i void checkEdgeList(Graph &G, int nn) -{ - typedef typename Graph::EdgeIt EdgeIt; - - EdgeIt e(G); - for(int i=0;i void checkOutEdgeList(Graph &G, - typename Graph::Node n, - int nn) -{ - typename Graph::OutEdgeIt e(G,n); - for(int i=0;i void checkInEdgeList(Graph &G, - typename Graph::Node n, - int nn) -{ - typename Graph::InEdgeIt e(G,n); - for(int i=0;i void bidirPetersen(Graph &G) { typedef typename Graph::Edge Edge; typedef typename Graph::EdgeIt EdgeIt; - checkEdgeList(G,15); + checkGraphEdgeList(G,15); std::vector ee; @@ -329,12 +41,12 @@ typedef typename Graph::EdgeIt EdgeIt; typedef typename Graph::NodeIt NodeIt; - checkNodeList(G,10); - checkEdgeList(G,30); + checkGraphNodeList(G,10); + checkGraphEdgeList(G,30); for(NodeIt n(G);n!=INVALID;++n) { - checkInEdgeList(G,n,3); - checkOutEdgeList(G,n,3); + checkGraphInEdgeList(G,n,3); + checkGraphOutEdgeList(G,n,3); ++n; } } @@ -343,44 +55,48 @@ template void checkCompileStaticGraph (skeleton::StaticGraphSkeleton &); -template void checkCompile(skeleton::GraphSkeleton &); +template void checkCompileGraph +(skeleton::GraphSkeleton &); -template void checkCompileErase +template void checkCompileErasableGraph (skeleton::EraseableGraphSkeleton &); //Compile SmartGraph -template void checkCompile(SmartGraph &); +template void checkCompileGraph(SmartGraph &); +template void checkCompileGraphFindEdge(SmartGraph &); //Compile SymSmartGraph -template void checkCompile(SymSmartGraph &); +template void checkCompileGraph(SymSmartGraph &); +template void checkCompileGraphFindEdge(SymSmartGraph &); //Compile ListGraph -template void checkCompile(ListGraph &); -template void checkCompileErase(ListGraph &); -template void checkCompileFindEdge(ListGraph &); +template void checkCompileGraph(ListGraph &); +template void checkCompileErasableGraph(ListGraph &); +template void checkCompileGraphFindEdge(ListGraph &); //Compile SymListGraph -template void checkCompile(SymListGraph &); -template void checkCompileErase(SymListGraph &); -template void checkCompileFindEdge(SymListGraph &); +template void checkCompileGraph(SymListGraph &); +template void checkCompileErasableGraph(SymListGraph &); +template void checkCompileGraphFindEdge(SymListGraph &); //Compile FullGraph template void checkCompileStaticGraph(FullGraph &); -template void checkCompileFindEdge(FullGraph &); +template void checkCompileGraphFindEdge(FullGraph &); //Compile EdgeSet -template void checkCompile >(EdgeSet &); -template -void checkCompileEraseEdge >(EdgeSet &); -template -void checkCompileFindEdge >(EdgeSet &); +template void checkCompileGraph >(EdgeSet &); +template void checkCompileGraphEraseEdge > +(EdgeSet &); +template void checkCompileGraphFindEdge > +(EdgeSet &); //Compile EdgeSet -template void checkCompile >(EdgeSet &); -template -void checkCompileEraseEdge >(EdgeSet &); -template void checkCompileFindEdge >(EdgeSet &); +template void checkCompileGraph >(EdgeSet &); +template void checkCompileGraphEraseEdge > +(EdgeSet &); +template void checkCompileGraphFindEdge > +(EdgeSet &); int main() diff -r 3393abe30678 -r b70a494b4912 src/test/graph_test.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/graph_test.h Fri Sep 03 17:34:22 2004 +0000 @@ -0,0 +1,306 @@ +#ifndef HUGO_TEST_GRAPH_TEST_H +#define HUGO_TEST_GRAPH_TEST_H + + +#include "test_tools.h" + +//! \ingroup misc +//! \file +//! \brief Some utility to test graph classes. +namespace hugo { + + +template void checkCompileStaticGraph(Graph &G) +{ + typedef typename Graph::Node Node; + typedef typename Graph::NodeIt NodeIt; + typedef typename Graph::Edge Edge; + typedef typename Graph::EdgeIt EdgeIt; + typedef typename Graph::InEdgeIt InEdgeIt; + typedef typename Graph::OutEdgeIt OutEdgeIt; + + { + Node i; Node j(i); Node k(INVALID); + i=j; + // bool b=G.valid(i); b=b; + bool b; b=b; + b=(i==INVALID); b=(i!=INVALID); + b=(i==j); b=(i!=j); b=(iNodeIt conversion + NodeIt ni(G,n); + } + { + Edge i; Edge j(i); Edge k(INVALID); + i=j; + // bool b=G.valid(i); b=b; + bool b; b=b; + b=(i==INVALID); b=(i!=INVALID); + b=(i==j); b=(i!=j); b=(iEdgeIt conversion + EdgeIt ei(G,e); + } + { + Node n; + InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n); + i=j; + j=G.first(i,n); + j=++i; + // bool b=G.valid(i); b=b; + bool b; b=b; + b=(i==INVALID); b=(i!=INVALID); + Edge e(i); + e=i; + b=(i==j); b=(i!=j); b=(iInEdgeIt conversion + InEdgeIt ei(G,e); + } + { + Node n; + OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n); + i=j; + j=G.first(i,n); + j=++i; + // bool b=G.valid(i); b=b; + bool b; b=b; + b=(i==INVALID); b=(i!=INVALID); + Edge e(i); + e=i; + b=(i==j); b=(i!=j); b=(iOutEdgeIt conversion + OutEdgeIt ei(G,e); + } + { + Node n,m; + n=m=INVALID; + Edge e; + e=INVALID; + n=G.tail(e); + n=G.head(e); + } + // id tests + { Node n; int i=G.id(n); i=i; } + { Edge e; int i=G.id(e); i=i; } + //NodeMap tests + { + Node k; + typename Graph::template NodeMap m(G); + //Const map + typename Graph::template NodeMap const &cm = m; + //Inicialize with default value + typename Graph::template NodeMap mdef(G,12); + //Copy + typename Graph::template NodeMap mm(cm); + //Copy from another type + typename Graph::template NodeMap dm(cm); + int v; + v=m[k]; m[k]=v; m.set(k,v); + v=cm[k]; + + m=cm; + dm=cm; //Copy from another type + { + //Check the typedef's + typename Graph::template NodeMap::ValueType val; + val=1; + typename Graph::template NodeMap::KeyType key; + key = typename Graph::NodeIt(G); + } + } + { //bool NodeMap + Node k; + typename Graph::template NodeMap m(G); + typename Graph::template NodeMap const &cm = m; //Const map + //Inicialize with default value + typename Graph::template NodeMap mdef(G,12); + typename Graph::template NodeMap mm(cm); //Copy + typename Graph::template NodeMap dm(cm); //Copy from another type + bool v; + v=m[k]; m[k]=v; m.set(k,v); + v=cm[k]; + + m=cm; + dm=cm; //Copy from another type + m=dm; //Copy to another type + + { + //Check the typedef's + typename Graph::template NodeMap::ValueType val; + val=true; + typename Graph::template NodeMap::KeyType key; + key= typename Graph::NodeIt(G); + } + } + //EdgeMap tests + { + Edge k; + typename Graph::template EdgeMap m(G); + typename Graph::template EdgeMap const &cm = m; //Const map + //Inicialize with default value + typename Graph::template EdgeMap mdef(G,12); + typename Graph::template EdgeMap mm(cm); //Copy + typename Graph::template EdgeMap dm(cm); //Copy from another type + int v; + v=m[k]; m[k]=v; m.set(k,v); + v=cm[k]; + + m=cm; + dm=cm; //Copy from another type + { + //Check the typedef's + typename Graph::template EdgeMap::ValueType val; + val=1; + typename Graph::template EdgeMap::KeyType key; + key= typename Graph::EdgeIt(G); + } + } + { //bool EdgeMap + Edge k; + typename Graph::template EdgeMap m(G); + typename Graph::template EdgeMap const &cm = m; //Const map + //Inicialize with default value + typename Graph::template EdgeMap mdef(G,12); + typename Graph::template EdgeMap mm(cm); //Copy + typename Graph::template EdgeMap dm(cm); //Copy from another type + bool v; + v=m[k]; m[k]=v; m.set(k,v); + v=cm[k]; + + m=cm; + dm=cm; //Copy from another type + m=dm; //Copy to another type + { + //Check the typedef's + typename Graph::template EdgeMap::ValueType val; + val=true; + typename Graph::template EdgeMap::KeyType key; + key= typename Graph::EdgeIt(G); + } + } +} + +template void checkCompileGraph(Graph &G) +{ + checkCompileStaticGraph(G); + + typedef typename Graph::Node Node; + typedef typename Graph::NodeIt NodeIt; + typedef typename Graph::Edge Edge; + typedef typename Graph::EdgeIt EdgeIt; + typedef typename Graph::InEdgeIt InEdgeIt; + typedef typename Graph::OutEdgeIt OutEdgeIt; + + Node n,m; + n=G.addNode(); + m=G.addNode(); + Edge e; + e=G.addEdge(n,m); + + // G.clear(); +} + +template void checkCompileGraphEraseEdge(Graph &G) +{ + typename Graph::Edge e; + G.erase(e); +} + +template void checkCompileGraphEraseNode(Graph &G) +{ + typename Graph::Node n; + G.erase(n); +} + +template void checkCompileErasableGraph(Graph &G) +{ + checkCompileGraph(G); + checkCompileGraphEraseNode(G); + checkCompileGraphEraseEdge(G); +} + +template void checkCompileGraphFindEdge(Graph &G) +{ + typedef typename Graph::NodeIt Node; + typedef typename Graph::NodeIt NodeIt; + + G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G))); + G.findEdge(Node(),Node(),G.findEdge(Node(),Node())); +} + +template void checkGraphNodeList(Graph &G, int nn) +{ + typename Graph::NodeIt n(G); + for(int i=0;i void checkGraphEdgeList(Graph &G, int nn) +{ + typedef typename Graph::EdgeIt EdgeIt; + + EdgeIt e(G); + for(int i=0;i void checkGraphOutEdgeList(Graph &G, + typename Graph::Node n, + int nn) +{ + typename Graph::OutEdgeIt e(G,n); + for(int i=0;i void checkGraphInEdgeList(Graph &G, + typename Graph::Node n, + int nn) +{ + typename Graph::InEdgeIt e(G,n); + for(int i=0;i