1.1 --- a/test/bfs_test.cc Sun Jun 15 22:03:33 2008 +0200
1.2 +++ b/test/bfs_test.cc Sun Jun 15 22:05:23 2008 +0200
1.3 @@ -16,32 +16,25 @@
1.4 *
1.5 */
1.6
1.7 -#include "test_tools.h"
1.8 -//#include <lemon/smart_graph.h>
1.9 +#include <lemon/concepts/digraph.h>
1.10 +#include <lemon/smart_graph.h>
1.11 #include <lemon/list_graph.h>
1.12 #include <lemon/bfs.h>
1.13 #include <lemon/path.h>
1.14 -#include<lemon/concepts/digraph.h>
1.15 +
1.16 +#include "graph_test.h"
1.17 +#include "test_tools.h"
1.18
1.19 using namespace lemon;
1.20
1.21 -const int PET_SIZE =5;
1.22 -
1.23 -
1.24 -void check_Bfs_Compile()
1.25 +void checkBfsCompile()
1.26 {
1.27 typedef concepts::Digraph Digraph;
1.28 -
1.29 - typedef Digraph::Arc Arc;
1.30 - typedef Digraph::Node Node;
1.31 - typedef Digraph::ArcIt ArcIt;
1.32 - typedef Digraph::NodeIt NodeIt;
1.33 -
1.34 typedef Bfs<Digraph> BType;
1.35
1.36 Digraph G;
1.37 - Node n;
1.38 - Arc e;
1.39 + Digraph::Node n;
1.40 + Digraph::Arc e;
1.41 int l;
1.42 bool b;
1.43 BType::DistMap d(G);
1.44 @@ -63,16 +56,12 @@
1.45 Path<Digraph> pp = bfs_test.path(n);
1.46 }
1.47
1.48 -void check_Bfs_Function_Compile()
1.49 +void checkBfsFunctionCompile()
1.50 {
1.51 typedef int VType;
1.52 typedef concepts::Digraph Digraph;
1.53 -
1.54 typedef Digraph::Arc Arc;
1.55 typedef Digraph::Node Node;
1.56 - typedef Digraph::ArcIt ArcIt;
1.57 - typedef Digraph::NodeIt NodeIt;
1.58 - typedef concepts::ReadMap<Arc,VType> LengthMap;
1.59
1.60 Digraph g;
1.61 bfs(g,Node()).run();
1.62 @@ -83,24 +72,15 @@
1.63 .reachedMap(concepts::ReadWriteMap<Node,bool>())
1.64 .processedMap(concepts::WriteMap<Node,bool>())
1.65 .run(Node());
1.66 -
1.67 }
1.68
1.69 -int main()
1.70 -{
1.71 -
1.72 - // typedef SmartDigraph Digraph;
1.73 - typedef ListDigraph Digraph;
1.74 -
1.75 - typedef Digraph::Arc Arc;
1.76 - typedef Digraph::Node Node;
1.77 - typedef Digraph::ArcIt ArcIt;
1.78 - typedef Digraph::NodeIt NodeIt;
1.79 - typedef Digraph::ArcMap<int> LengthMap;
1.80 +template <class Digraph>
1.81 +void checkBfs() {
1.82 + TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
1.83
1.84 Digraph G;
1.85 Node s, t;
1.86 - PetStruct<Digraph> ps = addPetersen(G,PET_SIZE);
1.87 + PetStruct<Digraph> ps = addPetersen(G, 5);
1.88
1.89 s=ps.outer[2];
1.90 t=ps.inner[0];
1.91 @@ -108,10 +88,10 @@
1.92 Bfs<Digraph> bfs_test(G);
1.93 bfs_test.run(s);
1.94
1.95 - check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
1.96 + check(bfs_test.dist(t)==3,"Bfs found a wrong path." << bfs_test.dist(t));
1.97
1.98 Path<Digraph> p = bfs_test.path(t);
1.99 - check(p.length()==3,"getPath() found a wrong path.");
1.100 + check(p.length()==3,"path() found a wrong path.");
1.101 check(checkPath(G, p),"path() found a wrong path.");
1.102 check(pathSource(G, p) == s,"path() found a wrong path.");
1.103 check(pathTarget(G, p) == t,"path() found a wrong path.");
1.104 @@ -139,3 +119,9 @@
1.105 }
1.106 }
1.107
1.108 +int main()
1.109 +{
1.110 + checkBfs<ListDigraph>();
1.111 + checkBfs<SmartDigraph>();
1.112 + return 0;
1.113 +}