equal
deleted
inserted
replaced
1 /* -*- mode: C++; indent-tabs-mode: nil; -*- |
1 /* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 * |
2 * |
3 * This file is a part of LEMON, a generic C++ optimization library. |
3 * This file is a part of LEMON, a generic C++ optimization library. |
4 * |
4 * |
5 * Copyright (C) 2003-2011 |
5 * Copyright (C) 2003-2013 |
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 * (Egervary Research Group on Combinatorial Optimization, EGRES). |
7 * (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 * |
8 * |
9 * Permission to use, modify and distribute this software is granted |
9 * Permission to use, modify and distribute this software is granted |
10 * provided that this copyright notice appears in all copies. For |
10 * provided that this copyright notice appears in all copies. For |
61 "@arcs\n" |
61 "@arcs\n" |
62 " label -\n" |
62 " label -\n" |
63 "0 1\n"; |
63 "0 1\n"; |
64 |
64 |
65 |
65 |
66 int main() |
66 int main() |
67 { |
67 { |
68 { |
68 { |
69 ListDigraph d; |
69 ListDigraph d; |
70 ListDigraph::Node s,t; |
70 ListDigraph::Node s,t; |
71 ListDigraph::ArcMap<int> label(d); |
71 ListDigraph::ArcMap<int> label(d); |
72 std::istringstream input(test_lgf); |
72 std::istringstream input(test_lgf); |
73 digraphReader(d, input). |
73 digraphReader(d, input). |
74 node("source", s). |
74 node("source", s). |
91 check(countNodes(g) == 2,"There should be 2 nodes"); |
91 check(countNodes(g) == 2,"There should be 2 nodes"); |
92 check(countEdges(g) == 2,"There should be 2 arcs"); |
92 check(countEdges(g) == 2,"There should be 2 arcs"); |
93 } |
93 } |
94 |
94 |
95 { |
95 { |
96 ListDigraph d; |
96 ListDigraph d; |
97 std::istringstream input(test_lgf_nomap); |
97 std::istringstream input(test_lgf_nomap); |
98 digraphReader(d, input). |
98 digraphReader(d, input). |
99 run(); |
99 run(); |
100 check(countNodes(d) == 2,"There should be 2 nodes"); |
100 check(countNodes(d) == 2,"There should be 2 nodes"); |
101 check(countArcs(d) == 1,"There should be 1 arc"); |
101 check(countArcs(d) == 1,"There should be 1 arc"); |
108 check(countNodes(g) == 2,"There should be 2 nodes"); |
108 check(countNodes(g) == 2,"There should be 2 nodes"); |
109 check(countEdges(g) == 1,"There should be 1 edge"); |
109 check(countEdges(g) == 1,"There should be 1 edge"); |
110 } |
110 } |
111 |
111 |
112 { |
112 { |
113 ListDigraph d; |
113 ListDigraph d; |
114 std::istringstream input(test_lgf_bad1); |
114 std::istringstream input(test_lgf_bad1); |
115 bool ok=false; |
115 bool ok=false; |
116 try { |
116 try { |
117 digraphReader(d, input). |
117 digraphReader(d, input). |
118 run(); |
118 run(); |
119 } |
119 } |
120 catch (FormatError&) |
120 catch (FormatError&) |
121 { |
121 { |
122 ok = true; |
122 ok = true; |
123 } |
123 } |
124 check(ok,"FormatError exception should have occured"); |
124 check(ok,"FormatError exception should have occured"); |
125 } |
125 } |
137 } |
137 } |
138 check(ok,"FormatError exception should have occured"); |
138 check(ok,"FormatError exception should have occured"); |
139 } |
139 } |
140 |
140 |
141 { |
141 { |
142 ListDigraph d; |
142 ListDigraph d; |
143 std::istringstream input(test_lgf_bad2); |
143 std::istringstream input(test_lgf_bad2); |
144 bool ok=false; |
144 bool ok=false; |
145 try { |
145 try { |
146 digraphReader(d, input). |
146 digraphReader(d, input). |
147 run(); |
147 run(); |