Changeset 964:2b6bffe0e7e8 in lemon-main for test
- Timestamp:
- 12/20/11 18:15:14 (13 years ago)
- Branch:
- default
- Parents:
- 963:7c4ba7daaf5f (diff), 942:633956ca9421 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Phase:
- public
- Location:
- test
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
test/CMakeLists.txt
r874 r964 7 7 ${PROJECT_BINARY_DIR}/lemon 8 8 ) 9 10 SET(TEST_WITH_VALGRIND "NO" CACHE STRING 11 "Run the test with valgrind (YES/NO).") 12 SET(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.") 9 13 10 14 SET(TESTS … … 30 34 heap_test 31 35 kruskal_test 36 lgf_test 32 37 maps_test 33 38 matching_test … … 46 51 47 52 IF(LEMON_HAVE_LP) 48 ADD_EXECUTABLE(lp_test lp_test.cc) 53 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") 54 ADD_EXECUTABLE(lp_test lp_test.cc) 55 ELSE() 56 ADD_EXECUTABLE(lp_test EXCLUDE_FROM_ALL lp_test.cc) 57 ENDIF() 58 49 59 SET(LP_TEST_LIBS lemon) 50 60 … … 61 71 TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS}) 62 72 ADD_TEST(lp_test lp_test) 73 ADD_DEPENDENCIES(check lp_test) 63 74 64 75 IF(WIN32 AND LEMON_HAVE_GLPK) … … 82 93 83 94 IF(LEMON_HAVE_MIP) 84 ADD_EXECUTABLE(mip_test mip_test.cc) 95 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") 96 ADD_EXECUTABLE(mip_test mip_test.cc) 97 ELSE() 98 ADD_EXECUTABLE(mip_test EXCLUDE_FROM_ALL mip_test.cc) 99 ENDIF() 100 85 101 SET(MIP_TEST_LIBS lemon) 86 102 … … 97 113 TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS}) 98 114 ADD_TEST(mip_test mip_test) 115 ADD_DEPENDENCIES(check mip_test) 99 116 100 117 IF(WIN32 AND LEMON_HAVE_GLPK) … … 118 135 119 136 FOREACH(TEST_NAME ${TESTS}) 120 ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc) 137 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") 138 ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc) 139 ELSE() 140 ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc) 141 ENDIF() 121 142 TARGET_LINK_LIBRARIES(${TEST_NAME} lemon) 122 ADD_TEST(${TEST_NAME} ${TEST_NAME}) 143 IF(TEST_WITH_VALGRIND) 144 ADD_TEST(${TEST_NAME} 145 valgrind --error-exitcode=1 ${VALGRIND_FLAGS} 146 ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} ) 147 ELSE() 148 ADD_TEST(${TEST_NAME} ${TEST_NAME}) 149 ENDIF() 150 ADD_DEPENDENCIES(check ${TEST_NAME}) 123 151 ENDFOREACH() -
test/CMakeLists.txt
r959 r964 14 14 SET(TESTS 15 15 adaptors_test 16 bellman_ford_test 16 17 bfs_test 17 18 circulation_test … … 25 26 error_test 26 27 euler_test 28 fractional_matching_test 27 29 gomory_hu_test 28 30 graph_copy_test … … 37 39 min_cost_arborescence_test 38 40 min_cost_flow_test 41 min_mean_cycle_test 39 42 path_test 43 planarity_test 40 44 preflow_test 41 45 radix_sort_test -
test/Makefile.am
r874 r964 32 32 test/heap_test \ 33 33 test/kruskal_test \ 34 test/lgf_test \ 34 35 test/maps_test \ 35 36 test/matching_test \ … … 81 82 test_kruskal_test_SOURCES = test/kruskal_test.cc 82 83 test_hao_orlin_test_SOURCES = test/hao_orlin_test.cc 84 test_lgf_test_SOURCES = test/lgf_test.cc 83 85 test_lp_test_SOURCES = test/lp_test.cc 84 86 test_maps_test_SOURCES = test/maps_test.cc -
test/Makefile.am
r959 r964 1 if USE_VALGRIND 2 TESTS_ENVIRONMENT=$(top_srcdir)/scripts/valgrind-wrapper.sh 3 endif 4 1 5 EXTRA_DIST += \ 2 6 test/CMakeLists.txt … … 8 12 check_PROGRAMS += \ 9 13 test/adaptors_test \ 14 test/bellman_ford_test \ 10 15 test/bfs_test \ 11 16 test/circulation_test \ … … 19 24 test/error_test \ 20 25 test/euler_test \ 26 test/fractional_matching_test \ 21 27 test/gomory_hu_test \ 22 28 test/graph_copy_test \ … … 31 37 test/min_cost_arborescence_test \ 32 38 test/min_cost_flow_test \ 39 test/min_mean_cycle_test \ 33 40 test/path_test \ 41 test/planarity_test \ 34 42 test/preflow_test \ 35 43 test/radix_sort_test \ … … 54 62 55 63 test_adaptors_test_SOURCES = test/adaptors_test.cc 64 test_bellman_ford_test_SOURCES = test/bellman_ford_test.cc 56 65 test_bfs_test_SOURCES = test/bfs_test.cc 57 66 test_circulation_test_SOURCES = test/circulation_test.cc … … 65 74 test_error_test_SOURCES = test/error_test.cc 66 75 test_euler_test_SOURCES = test/euler_test.cc 76 test_fractional_matching_test_SOURCES = test/fractional_matching_test.cc 67 77 test_gomory_hu_test_SOURCES = test/gomory_hu_test.cc 68 78 test_graph_copy_test_SOURCES = test/graph_copy_test.cc … … 79 89 test_min_cost_arborescence_test_SOURCES = test/min_cost_arborescence_test.cc 80 90 test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc 91 test_min_mean_cycle_test_SOURCES = test/min_mean_cycle_test.cc 81 92 test_path_test_SOURCES = test/path_test.cc 93 test_planarity_test_SOURCES = test/planarity_test.cc 82 94 test_preflow_test_SOURCES = test/preflow_test.cc 83 95 test_radix_sort_test_SOURCES = test/radix_sort_test.cc -
test/dfs_test.cc
r877 r964 51 51 "@attributes\n" 52 52 "source 0\n" 53 "target 5\n"; 53 "target 5\n" 54 "source1 6\n" 55 "target1 3\n"; 56 54 57 55 58 void checkDfsCompile() … … 180 183 Digraph G; 181 184 Node s, t; 185 Node s1, t1; 182 186 183 187 std::istringstream input(test_lgf); … … 185 189 node("source", s). 186 190 node("target", t). 191 node("source1", s1). 192 node("target1", t1). 187 193 run(); 188 194 … … 211 217 212 218 { 219 Dfs<Digraph> dfs(G); 220 check(dfs.run(s1,t1) && dfs.reached(t1),"Node 3 is reachable from Node 6."); 221 } 222 223 { 213 224 NullMap<Node,Arc> myPredMap; 214 225 dfs(G).predMap(myPredMap).run(s); -
test/dfs_test.cc
r959 r964 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 87 87 b = const_dfs_test.emptyQueue(); 88 88 i = const_dfs_test.queueSize(); 89 89 90 90 dfs_test.start(); 91 91 dfs_test.start(t); … … 113 113 concepts::ReadWriteMap<Node,bool> reached_map; 114 114 concepts::WriteMap<Node,bool> processed_map; 115 115 116 116 dfs_test 117 117 .predMap(pred_map) … … 130 130 b = dfs_test.emptyQueue(); 131 131 i = dfs_test.queueSize(); 132 132 133 133 dfs_test.start(); 134 134 dfs_test.start(t); -
test/heap_test.cc
r855 r948 273 273 } 274 274 275 { 276 typedef FibHeap<Prio, ItemIntMap> IntHeap; 277 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 278 heapSortTest<IntHeap>(); 279 heapIncreaseTest<IntHeap>(); 280 281 typedef FibHeap<Prio, IntNodeMap > NodeHeap; 282 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 283 dijkstraHeapTest<NodeHeap>(digraph, length, source); 284 } 285 286 { 287 typedef RadixHeap<ItemIntMap> IntHeap; 288 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 289 heapSortTest<IntHeap>(); 290 heapIncreaseTest<IntHeap>(); 291 292 typedef RadixHeap<IntNodeMap > NodeHeap; 293 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 294 dijkstraHeapTest<NodeHeap>(digraph, length, source); 295 } 296 297 { 298 typedef BucketHeap<ItemIntMap> IntHeap; 299 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 300 heapSortTest<IntHeap>(); 301 heapIncreaseTest<IntHeap>(); 302 303 typedef BucketHeap<IntNodeMap > NodeHeap; 304 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 305 dijkstraHeapTest<NodeHeap>(digraph, length, source); 306 } 307 308 275 309 return 0; 276 310 } -
test/heap_test.cc
r681 r948 26 26 27 27 #include <lemon/smart_graph.h> 28 29 28 #include <lemon/lgf_reader.h> 30 29 #include <lemon/dijkstra.h> … … 32 31 33 32 #include <lemon/bin_heap.h> 33 #include <lemon/quad_heap.h> 34 #include <lemon/dheap.h> 34 35 #include <lemon/fib_heap.h> 36 #include <lemon/pairing_heap.h> 35 37 #include <lemon/radix_heap.h> 38 #include <lemon/binomial_heap.h> 36 39 #include <lemon/bucket_heap.h> 37 40 … … 90 93 void heapSortTest() { 91 94 RangeMap<int> map(test_len, -1); 92 93 95 Heap heap(map); 94 96 95 97 std::vector<int> v(test_len); 96 97 98 for (int i = 0; i < test_len; ++i) { 98 99 v[i] = test_seq[i]; … … 101 102 std::sort(v.begin(), v.end()); 102 103 for (int i = 0; i < test_len; ++i) { 103 check(v[i] == heap.prio() ,"Wrong order in heap sort.");104 check(v[i] == heap.prio(), "Wrong order in heap sort."); 104 105 heap.pop(); 105 106 } … … 113 114 114 115 std::vector<int> v(test_len); 115 116 116 for (int i = 0; i < test_len; ++i) { 117 117 v[i] = test_seq[i]; … … 124 124 std::sort(v.begin(), v.end()); 125 125 for (int i = 0; i < test_len; ++i) { 126 check(v[i] == heap.prio() ,"Wrong order in heap increase test.");126 check(v[i] == heap.prio(), "Wrong order in heap increase test."); 127 127 heap.pop(); 128 128 } 129 129 } 130 131 132 130 133 131 template <typename Heap> … … 145 143 if (dijkstra.reached(s)) { 146 144 check( dijkstra.dist(t) - dijkstra.dist(s) <= length[a], 147 "Error in a shortest path tree!");145 "Error in shortest path tree."); 148 146 } 149 147 } … … 154 152 Node s = digraph.source(a); 155 153 check( dijkstra.dist(n) - dijkstra.dist(s) == length[a], 156 "Error in a shortest path tree!");154 "Error in shortest path tree."); 157 155 } 158 156 } … … 176 174 run(); 177 175 176 // BinHeap 178 177 { 179 178 typedef BinHeap<Prio, ItemIntMap> IntHeap; … … 185 184 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 186 185 dijkstraHeapTest<NodeHeap>(digraph, length, source); 186 } 187 188 // QuadHeap 189 { 190 typedef QuadHeap<Prio, ItemIntMap> IntHeap; 191 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 192 heapSortTest<IntHeap>(); 193 heapIncreaseTest<IntHeap>(); 194 195 typedef QuadHeap<Prio, IntNodeMap > NodeHeap; 196 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 197 dijkstraHeapTest<NodeHeap>(digraph, length, source); 198 } 199 200 // DHeap 201 { 202 typedef DHeap<Prio, ItemIntMap> IntHeap; 203 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 204 heapSortTest<IntHeap>(); 205 heapIncreaseTest<IntHeap>(); 206 207 typedef DHeap<Prio, IntNodeMap > NodeHeap; 208 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 209 dijkstraHeapTest<NodeHeap>(digraph, length, source); 210 } 211 212 // FibHeap 213 { 214 typedef FibHeap<Prio, ItemIntMap> IntHeap; 215 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 216 heapSortTest<IntHeap>(); 217 heapIncreaseTest<IntHeap>(); 218 219 typedef FibHeap<Prio, IntNodeMap > NodeHeap; 220 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 221 dijkstraHeapTest<NodeHeap>(digraph, length, source); 222 } 223 224 // PairingHeap 225 { 226 typedef PairingHeap<Prio, ItemIntMap> IntHeap; 227 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 228 heapSortTest<IntHeap>(); 229 heapIncreaseTest<IntHeap>(); 230 231 typedef PairingHeap<Prio, IntNodeMap > NodeHeap; 232 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 233 dijkstraHeapTest<NodeHeap>(digraph, length, source); 234 } 235 236 // RadixHeap 237 { 238 typedef RadixHeap<ItemIntMap> IntHeap; 239 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 240 heapSortTest<IntHeap>(); 241 heapIncreaseTest<IntHeap>(); 242 243 typedef RadixHeap<IntNodeMap > NodeHeap; 244 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 245 dijkstraHeapTest<NodeHeap>(digraph, length, source); 246 } 247 248 // BinomialHeap 249 { 250 typedef BinomialHeap<Prio, ItemIntMap> IntHeap; 251 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 252 heapSortTest<IntHeap>(); 253 heapIncreaseTest<IntHeap>(); 254 255 typedef BinomialHeap<Prio, IntNodeMap > NodeHeap; 256 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 257 dijkstraHeapTest<NodeHeap>(digraph, length, source); 258 } 259 260 // BucketHeap, SimpleBucketHeap 261 { 262 typedef BucketHeap<ItemIntMap> IntHeap; 263 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); 264 heapSortTest<IntHeap>(); 265 heapIncreaseTest<IntHeap>(); 266 267 typedef BucketHeap<IntNodeMap > NodeHeap; 268 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); 269 dijkstraHeapTest<NodeHeap>(digraph, length, source); 270 271 typedef SimpleBucketHeap<ItemIntMap> SimpleIntHeap; 272 heapSortTest<SimpleIntHeap>(); 187 273 } 188 274 -
test/preflow_test.cc
r877 r924 157 157 } 158 158 159 void initFlowTest() 160 { 161 DIGRAPH_TYPEDEFS(SmartDigraph); 162 163 SmartDigraph g; 164 SmartDigraph::ArcMap<int> cap(g),iflow(g); 165 Node s=g.addNode(); Node t=g.addNode(); 166 Node n1=g.addNode(); Node n2=g.addNode(); 167 Arc a; 168 a=g.addArc(s,n1); cap[a]=20; iflow[a]=20; 169 a=g.addArc(n1,n2); cap[a]=10; iflow[a]=0; 170 a=g.addArc(n2,t); cap[a]=20; iflow[a]=0; 171 172 Preflow<SmartDigraph> pre(g,cap,s,t); 173 pre.init(iflow); 174 pre.startFirstPhase(); 175 check(pre.flowValue() == 10, "The incorrect max flow value."); 176 check(pre.minCut(s), "Wrong min cut (Node s)."); 177 check(pre.minCut(n1), "Wrong min cut (Node n1)."); 178 check(!pre.minCut(n2), "Wrong min cut (Node n2)."); 179 check(!pre.minCut(t), "Wrong min cut (Node t)."); 180 } 181 182 159 183 int main() { 160 184 … … 247 271 "The max flow value or the three min cut values are incorrect."); 248 272 273 initFlowTest(); 274 249 275 return 0; 250 276 } -
test/preflow_test.cc
r923 r924 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 095 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 96 96 const PreflowType& const_preflow_test = preflow_test; 97 97 98 const PreflowType::Elevator& elev = const_preflow_test.elevator(); 99 preflow_test.elevator(const_cast<PreflowType::Elevator&>(elev)); 100 PreflowType::Tolerance tol = const_preflow_test.tolerance(); 101 preflow_test.tolerance(tol); 102 98 103 preflow_test 99 104 .capacityMap(cap) … … 114 119 b = const_preflow_test.minCut(n); 115 120 const_preflow_test.minCutMap(cut); 116 121 117 122 ignore_unused_variable_warning(fm); 118 123 }
Note: See TracChangeset
for help on using the changeset viewer.