1.1 --- a/test/CMakeLists.txt Mon Dec 08 11:06:39 2008 +0100
1.2 +++ b/test/CMakeLists.txt Mon Dec 08 15:47:20 2008 +0000
1.3 @@ -4,12 +4,14 @@
1.4
1.5 SET(TESTS
1.6 bfs_test
1.7 + circulation_test
1.8 counter_test
1.9 dfs_test
1.10 digraph_test
1.11 dijkstra_test
1.12 dim_test
1.13 error_test
1.14 + graph_adaptor_test
1.15 graph_copy_test
1.16 graph_test
1.17 graph_utils_test
1.18 @@ -18,8 +20,10 @@
1.19 kruskal_test
1.20 maps_test
1.21 max_matching_test
1.22 + path_test
1.23 + preflow_test
1.24 random_test
1.25 - path_test
1.26 + suurballe_test
1.27 time_measure_test
1.28 unionfind_test)
1.29
2.1 --- a/test/Makefile.am Mon Dec 08 11:06:39 2008 +0100
2.2 +++ b/test/Makefile.am Mon Dec 08 15:47:20 2008 +0000
2.3 @@ -1,7 +1,5 @@
2.4 EXTRA_DIST += \
2.5 - test/CMakeLists.txt \
2.6 - test/min_cost_flow_test.lgf \
2.7 - test/preflow_graph.lgf
2.8 + test/CMakeLists.txt
2.9
2.10 noinst_HEADERS += \
2.11 test/graph_test.h \
2.12 @@ -20,14 +18,14 @@
2.13 test/graph_copy_test \
2.14 test/graph_test \
2.15 test/graph_utils_test \
2.16 + test/hao_orlin_test \
2.17 test/heap_test \
2.18 test/kruskal_test \
2.19 - test/hao_orlin_test \
2.20 test/maps_test \
2.21 test/max_matching_test \
2.22 - test/random_test \
2.23 test/path_test \
2.24 test/preflow_test \
2.25 + test/random_test \
2.26 test/suurballe_test \
2.27 test/test_tools_fail \
2.28 test/test_tools_pass \
3.1 --- a/test/min_cost_flow_test.lgf Mon Dec 08 11:06:39 2008 +0100
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,44 +0,0 @@
3.4 -@nodes
3.5 -label supply1 supply2 supply3
3.6 -1 0 20 27
3.7 -2 0 -4 0
3.8 -3 0 0 0
3.9 -4 0 0 0
3.10 -5 0 9 0
3.11 -6 0 -6 0
3.12 -7 0 0 0
3.13 -8 0 0 0
3.14 -9 0 3 0
3.15 -10 0 -2 0
3.16 -11 0 0 0
3.17 -12 0 -20 -27
3.18 -
3.19 -@arcs
3.20 - cost capacity lower1 lower2
3.21 -1 2 70 11 0 8
3.22 -1 3 150 3 0 1
3.23 -1 4 80 15 0 2
3.24 -2 8 80 12 0 0
3.25 -3 5 140 5 0 3
3.26 -4 6 60 10 0 1
3.27 -4 7 80 2 0 0
3.28 -4 8 110 3 0 0
3.29 -5 7 60 14 0 0
3.30 -5 11 120 12 0 0
3.31 -6 3 0 3 0 0
3.32 -6 9 140 4 0 0
3.33 -6 10 90 8 0 0
3.34 -7 1 30 5 0 0
3.35 -8 12 60 16 0 4
3.36 -9 12 50 6 0 0
3.37 -10 12 70 13 0 5
3.38 -10 2 100 7 0 0
3.39 -10 7 60 10 0 0
3.40 -11 10 20 14 0 6
3.41 -12 11 30 10 0 0
3.42 -
3.43 -@attributes
3.44 -source 1
3.45 -target 12
3.46 -
3.47 -@end
4.1 --- a/test/preflow_graph.lgf Mon Dec 08 11:06:39 2008 +0100
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,34 +0,0 @@
4.4 -@nodes
4.5 -label
4.6 -0
4.7 -1
4.8 -2
4.9 -3
4.10 -4
4.11 -5
4.12 -6
4.13 -7
4.14 -8
4.15 -9
4.16 -@arcs
4.17 - label capacity
4.18 -0 1 0 20
4.19 -0 2 1 0
4.20 -1 1 2 3
4.21 -1 2 3 8
4.22 -1 3 4 8
4.23 -2 5 5 5
4.24 -3 2 6 5
4.25 -3 5 7 5
4.26 -3 6 8 5
4.27 -4 3 9 3
4.28 -5 7 10 3
4.29 -5 6 11 10
4.30 -5 8 12 10
4.31 -6 8 13 8
4.32 -8 9 14 20
4.33 -8 1 15 5
4.34 -9 5 16 5
4.35 -@attributes
4.36 -source 1
4.37 -target 8
5.1 --- a/test/preflow_test.cc Mon Dec 08 11:06:39 2008 +0100
5.2 +++ b/test/preflow_test.cc Mon Dec 08 15:47:20 2008 +0000
5.3 @@ -16,8 +16,7 @@
5.4 *
5.5 */
5.6
5.7 -#include <fstream>
5.8 -#include <string>
5.9 +#include <iostream>
5.10
5.11 #include "test_tools.h"
5.12 #include <lemon/smart_graph.h>
5.13 @@ -29,6 +28,42 @@
5.14
5.15 using namespace lemon;
5.16
5.17 +char test_lgf[] =
5.18 + "@nodes\n"
5.19 + "label\n"
5.20 + "0\n"
5.21 + "1\n"
5.22 + "2\n"
5.23 + "3\n"
5.24 + "4\n"
5.25 + "5\n"
5.26 + "6\n"
5.27 + "7\n"
5.28 + "8\n"
5.29 + "9\n"
5.30 + "@arcs\n"
5.31 + " label capacity\n"
5.32 + "0 1 0 20\n"
5.33 + "0 2 1 0\n"
5.34 + "1 1 2 3\n"
5.35 + "1 2 3 8\n"
5.36 + "1 3 4 8\n"
5.37 + "2 5 5 5\n"
5.38 + "3 2 6 5\n"
5.39 + "3 5 7 5\n"
5.40 + "3 6 8 5\n"
5.41 + "4 3 9 3\n"
5.42 + "5 7 10 3\n"
5.43 + "5 6 11 10\n"
5.44 + "5 8 12 10\n"
5.45 + "6 8 13 8\n"
5.46 + "8 9 14 20\n"
5.47 + "8 1 15 5\n"
5.48 + "9 5 16 5\n"
5.49 + "@attributes\n"
5.50 + "source 1\n"
5.51 + "target 8\n";
5.52 +
5.53 void checkPreflowCompile()
5.54 {
5.55 typedef int VType;
5.56 @@ -123,20 +158,11 @@
5.57
5.58 typedef Preflow<Digraph, CapMap> PType;
5.59
5.60 - std::string f_name;
5.61 - if( getenv("srcdir") )
5.62 - f_name = std::string(getenv("srcdir"));
5.63 - else f_name = ".";
5.64 - f_name += "/test/preflow_graph.lgf";
5.65 -
5.66 - std::ifstream file(f_name.c_str());
5.67 -
5.68 - check(file, "Input file '" << f_name << "' not found.");
5.69 -
5.70 Digraph g;
5.71 Node s, t;
5.72 CapMap cap(g);
5.73 - DigraphReader<Digraph>(g,file).
5.74 + std::istringstream input(test_lgf);
5.75 + DigraphReader<Digraph>(g,input).
5.76 arcMap("capacity", cap).
5.77 node("source",s).
5.78 node("target",t).
6.1 --- a/test/suurballe_test.cc Mon Dec 08 11:06:39 2008 +0100
6.2 +++ b/test/suurballe_test.cc Mon Dec 08 15:47:20 2008 +0000
6.3 @@ -17,7 +17,6 @@
6.4 */
6.5
6.6 #include <iostream>
6.7 -#include <fstream>
6.8
6.9 #include <lemon/list_graph.h>
6.10 #include <lemon/lgf_reader.h>
6.11 @@ -28,6 +27,49 @@
6.12
6.13 using namespace lemon;
6.14
6.15 +char test_lgf[] =
6.16 + "@nodes\n"
6.17 + "label supply1 supply2 supply3\n"
6.18 + "1 0 20 27\n"
6.19 + "2 0 -4 0\n"
6.20 + "3 0 0 0\n"
6.21 + "4 0 0 0\n"
6.22 + "5 0 9 0\n"
6.23 + "6 0 -6 0\n"
6.24 + "7 0 0 0\n"
6.25 + "8 0 0 0\n"
6.26 + "9 0 3 0\n"
6.27 + "10 0 -2 0\n"
6.28 + "11 0 0 0\n"
6.29 + "12 0 -20 -27\n"
6.30 + "@arcs\n"
6.31 + " cost capacity lower1 lower2\n"
6.32 + " 1 2 70 11 0 8\n"
6.33 + " 1 3 150 3 0 1\n"
6.34 + " 1 4 80 15 0 2\n"
6.35 + " 2 8 80 12 0 0\n"
6.36 + " 3 5 140 5 0 3\n"
6.37 + " 4 6 60 10 0 1\n"
6.38 + " 4 7 80 2 0 0\n"
6.39 + " 4 8 110 3 0 0\n"
6.40 + " 5 7 60 14 0 0\n"
6.41 + " 5 11 120 12 0 0\n"
6.42 + " 6 3 0 3 0 0\n"
6.43 + " 6 9 140 4 0 0\n"
6.44 + " 6 10 90 8 0 0\n"
6.45 + " 7 1 30 5 0 0\n"
6.46 + " 8 12 60 16 0 4\n"
6.47 + " 9 12 50 6 0 0\n"
6.48 + "10 12 70 13 0 5\n"
6.49 + "10 2 100 7 0 0\n"
6.50 + "10 7 60 10 0 0\n"
6.51 + "11 10 20 14 0 6\n"
6.52 + "12 11 30 10 0 0\n"
6.53 + "@attributes\n"
6.54 + "source 1\n"
6.55 + "target 12\n"
6.56 + "@end\n";
6.57 +
6.58 // Check the feasibility of the flow
6.59 template <typename Digraph, typename FlowMap>
6.60 bool checkFlow( const Digraph& gr, const FlowMap& flow,
6.61 @@ -96,20 +138,12 @@
6.62 ListDigraph::ArcMap<int> length(digraph);
6.63 Node source, target;
6.64
6.65 - std::string fname;
6.66 - if(getenv("srcdir"))
6.67 - fname = std::string(getenv("srcdir"));
6.68 - else fname = ".";
6.69 - fname += "/test/min_cost_flow_test.lgf";
6.70 -
6.71 - std::ifstream input(fname.c_str());
6.72 - check(input, "Input file '" << fname << "' not found");
6.73 + std::istringstream input(test_lgf);
6.74 DigraphReader<ListDigraph>(digraph, input).
6.75 arcMap("cost", length).
6.76 node("source", source).
6.77 node("target", target).
6.78 run();
6.79 - input.close();
6.80
6.81 // Find 2 paths
6.82 {