Inline the test input files into the source code
authorAlpar Juttner <alpar@cs.elte.hu>
Mon, 08 Dec 2008 15:18:04 +0000
changeset 442ff48c2738fb2
parent 439 62c1ed05e83f
child 443 346991bf7ddd
Inline the test input files into the source code
test/Makefile.am
test/min_cost_flow_test.lgf
test/preflow_graph.lgf
test/preflow_test.cc
test/suurballe_test.cc
     1.1 --- a/test/Makefile.am	Fri Dec 05 13:10:16 2008 +0000
     1.2 +++ b/test/Makefile.am	Mon Dec 08 15:18:04 2008 +0000
     1.3 @@ -1,7 +1,5 @@
     1.4  EXTRA_DIST += \
     1.5 -	test/CMakeLists.txt \
     1.6 -        test/min_cost_flow_test.lgf \
     1.7 -        test/preflow_graph.lgf
     1.8 +	test/CMakeLists.txt
     1.9  
    1.10  noinst_HEADERS += \
    1.11  	test/graph_test.h \
     2.1 --- a/test/min_cost_flow_test.lgf	Fri Dec 05 13:10:16 2008 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,44 +0,0 @@
     2.4 -@nodes
     2.5 -label	supply1	supply2	supply3
     2.6 -1	0	20	27	
     2.7 -2	0	-4	0		
     2.8 -3	0	0	0	
     2.9 -4	0	0	0	
    2.10 -5	0	9	0	
    2.11 -6	0	-6	0	
    2.12 -7	0	0	0	
    2.13 -8	0	0	0	
    2.14 -9	0	3	0	
    2.15 -10	0	-2	0	
    2.16 -11	0	0	0		
    2.17 -12	0	-20	-27	
    2.18 -               
    2.19 -@arcs
    2.20 -		cost	capacity	lower1	lower2
    2.21 -1	2	70	11		0	8
    2.22 -1	3	150	3		0	1
    2.23 -1	4	80	15		0	2
    2.24 -2	8	80	12		0	0
    2.25 -3	5	140	5		0	3
    2.26 -4	6	60	10		0	1
    2.27 -4	7	80	2		0	0
    2.28 -4	8	110	3		0	0
    2.29 -5	7	60	14		0	0
    2.30 -5	11	120	12		0	0
    2.31 -6	3	0	3		0	0
    2.32 -6	9	140	4		0	0
    2.33 -6	10	90	8		0	0
    2.34 -7	1	30	5		0	0
    2.35 -8	12	60	16		0	4
    2.36 -9	12	50	6		0	0
    2.37 -10	12	70	13		0	5
    2.38 -10	2	100	7		0	0
    2.39 -10	7	60	10		0	0
    2.40 -11	10	20	14		0	6
    2.41 -12	11	30	10		0	0
    2.42 -
    2.43 -@attributes
    2.44 -source	1
    2.45 -target	12
    2.46 -
    2.47 -@end
     3.1 --- a/test/preflow_graph.lgf	Fri Dec 05 13:10:16 2008 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,34 +0,0 @@
     3.4 -@nodes
     3.5 -label
     3.6 -0
     3.7 -1
     3.8 -2
     3.9 -3
    3.10 -4
    3.11 -5
    3.12 -6
    3.13 -7
    3.14 -8
    3.15 -9
    3.16 -@arcs
    3.17 -		label	capacity
    3.18 -0	1	0	20
    3.19 -0	2	1	0
    3.20 -1	1	2	3
    3.21 -1	2	3	8
    3.22 -1	3	4	8
    3.23 -2	5	5	5
    3.24 -3	2	6	5
    3.25 -3	5	7	5
    3.26 -3	6	8	5
    3.27 -4	3	9	3
    3.28 -5	7	10	3
    3.29 -5	6	11	10
    3.30 -5	8	12	10
    3.31 -6	8	13	8
    3.32 -8	9	14	20
    3.33 -8	1	15	5
    3.34 -9	5	16	5
    3.35 -@attributes
    3.36 -source 1
    3.37 -target 8
     4.1 --- a/test/preflow_test.cc	Fri Dec 05 13:10:16 2008 +0000
     4.2 +++ b/test/preflow_test.cc	Mon Dec 08 15:18:04 2008 +0000
     4.3 @@ -16,8 +16,7 @@
     4.4   *
     4.5   */
     4.6  
     4.7 -#include <fstream>
     4.8 -#include <string>
     4.9 +#include <iostream>
    4.10  
    4.11  #include "test_tools.h"
    4.12  #include <lemon/smart_graph.h>
    4.13 @@ -29,6 +28,42 @@
    4.14  
    4.15  using namespace lemon;
    4.16  
    4.17 +char test_lgf[] =
    4.18 +  "@nodes\n"
    4.19 +  "label\n"
    4.20 +  "0\n"
    4.21 +  "1\n"
    4.22 +  "2\n"
    4.23 +  "3\n"
    4.24 +  "4\n"
    4.25 +  "5\n"
    4.26 +  "6\n"
    4.27 +  "7\n"
    4.28 +  "8\n"
    4.29 +  "9\n"
    4.30 +  "@arcs\n"
    4.31 +  "    label capacity\n"
    4.32 +  "0 1 0     20\n"
    4.33 +  "0 2 1     0\n"
    4.34 +  "1 1 2     3\n"
    4.35 +  "1 2 3     8\n"
    4.36 +  "1 3 4     8\n"
    4.37 +  "2 5 5     5\n"
    4.38 +  "3 2 6     5\n"
    4.39 +  "3 5 7     5\n"
    4.40 +  "3 6 8     5\n"
    4.41 +  "4 3 9     3\n"
    4.42 +  "5 7 10    3\n"
    4.43 +  "5 6 11    10\n"
    4.44 +  "5 8 12    10\n"
    4.45 +  "6 8 13    8\n"
    4.46 +  "8 9 14    20\n"
    4.47 +  "8 1 15    5\n"
    4.48 +  "9 5 16    5\n"
    4.49 +  "@attributes\n"
    4.50 +  "source 1\n"
    4.51 +  "target 8\n";
    4.52 +
    4.53  void checkPreflowCompile()
    4.54  {
    4.55    typedef int VType;
    4.56 @@ -123,20 +158,11 @@
    4.57  
    4.58    typedef Preflow<Digraph, CapMap> PType;
    4.59  
    4.60 -  std::string f_name;
    4.61 -  if( getenv("srcdir") )
    4.62 -    f_name = std::string(getenv("srcdir"));
    4.63 -  else f_name = ".";
    4.64 -  f_name += "/test/preflow_graph.lgf";
    4.65 -
    4.66 -  std::ifstream file(f_name.c_str());
    4.67 -
    4.68 -  check(file, "Input file '" << f_name << "' not found.");
    4.69 -
    4.70    Digraph g;
    4.71    Node s, t;
    4.72    CapMap cap(g);
    4.73 -  DigraphReader<Digraph>(g,file).
    4.74 +  std::istringstream input(test_lgf);
    4.75 +  DigraphReader<Digraph>(g,input).
    4.76      arcMap("capacity", cap).
    4.77      node("source",s).
    4.78      node("target",t).
     5.1 --- a/test/suurballe_test.cc	Fri Dec 05 13:10:16 2008 +0000
     5.2 +++ b/test/suurballe_test.cc	Mon Dec 08 15:18:04 2008 +0000
     5.3 @@ -17,7 +17,6 @@
     5.4   */
     5.5  
     5.6  #include <iostream>
     5.7 -#include <fstream>
     5.8  
     5.9  #include <lemon/list_graph.h>
    5.10  #include <lemon/lgf_reader.h>
    5.11 @@ -28,6 +27,49 @@
    5.12  
    5.13  using namespace lemon;
    5.14  
    5.15 +char test_lgf[] =
    5.16 +  "@nodes\n"
    5.17 +  "label supply1 supply2 supply3\n"
    5.18 +  "1     0        20      27\n"
    5.19 +  "2     0       -4        0\n"
    5.20 +  "3     0        0        0\n"
    5.21 +  "4     0        0        0\n"
    5.22 +  "5     0        9        0\n"
    5.23 +  "6     0       -6        0\n"
    5.24 +  "7     0        0        0\n"
    5.25 +  "8     0        0        0\n"
    5.26 +  "9     0        3        0\n"
    5.27 +  "10    0       -2        0\n"
    5.28 +  "11    0        0        0\n"
    5.29 +  "12    0       -20     -27\n"
    5.30 +  "@arcs\n"
    5.31 +  "      cost capacity lower1 lower2\n"
    5.32 +  " 1  2  70  11       0      8\n"
    5.33 +  " 1  3 150   3       0      1\n"
    5.34 +  " 1  4  80  15       0      2\n"
    5.35 +  " 2  8  80  12       0      0\n"
    5.36 +  " 3  5 140   5       0      3\n"
    5.37 +  " 4  6  60  10       0      1\n"
    5.38 +  " 4  7  80   2       0      0\n"
    5.39 +  " 4  8 110   3       0      0\n"
    5.40 +  " 5  7  60  14       0      0\n"
    5.41 +  " 5 11 120  12       0      0\n"
    5.42 +  " 6  3   0   3       0      0\n"
    5.43 +  " 6  9 140   4       0      0\n"
    5.44 +  " 6 10  90   8       0      0\n"
    5.45 +  " 7  1  30   5       0      0\n"
    5.46 +  " 8 12  60  16       0      4\n"
    5.47 +  " 9 12  50   6       0      0\n"
    5.48 +  "10 12  70  13       0      5\n"
    5.49 +  "10  2 100   7       0      0\n"
    5.50 +  "10  7  60  10       0      0\n"
    5.51 +  "11 10  20  14       0      6\n"
    5.52 +  "12 11  30  10       0      0\n"
    5.53 +  "@attributes\n"
    5.54 +  "source  1\n"
    5.55 +  "target 12\n"
    5.56 +  "@end\n";
    5.57 +
    5.58  // Check the feasibility of the flow
    5.59  template <typename Digraph, typename FlowMap>
    5.60  bool checkFlow( const Digraph& gr, const FlowMap& flow, 
    5.61 @@ -96,20 +138,12 @@
    5.62    ListDigraph::ArcMap<int> length(digraph);
    5.63    Node source, target;
    5.64  
    5.65 -  std::string fname;
    5.66 -  if(getenv("srcdir"))
    5.67 -    fname = std::string(getenv("srcdir"));
    5.68 -  else fname = ".";
    5.69 -  fname += "/test/min_cost_flow_test.lgf";
    5.70 -
    5.71 -  std::ifstream input(fname.c_str());
    5.72 -  check(input, "Input file '" << fname << "' not found");
    5.73 +  std::istringstream input(test_lgf);
    5.74    DigraphReader<ListDigraph>(digraph, input).
    5.75      arcMap("cost", length).
    5.76      node("source", source).
    5.77      node("target", target).
    5.78      run();
    5.79 -  input.close();
    5.80    
    5.81    // Find 2 paths
    5.82    {