Changes in test/heap_test.cc [749:bdc7dfc8c054:463:88ed40ad0d4f] in lemon
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/heap_test.cc
r749 r463 26 26 27 27 #include <lemon/smart_graph.h> 28 28 29 #include <lemon/lgf_reader.h> 29 30 #include <lemon/dijkstra.h> … … 31 32 32 33 #include <lemon/bin_heap.h> 33 #include <lemon/fourary_heap.h>34 #include <lemon/kary_heap.h>35 #include <lemon/fib_heap.h>36 #include <lemon/pairing_heap.h>37 #include <lemon/radix_heap.h>38 #include <lemon/binom_heap.h>39 #include <lemon/bucket_heap.h>40 34 41 35 #include "test_tools.h" … … 93 87 void heapSortTest() { 94 88 RangeMap<int> map(test_len, -1); 89 95 90 Heap heap(map); 96 91 97 92 std::vector<int> v(test_len); 93 98 94 for (int i = 0; i < test_len; ++i) { 99 95 v[i] = test_seq[i]; … … 102 98 std::sort(v.begin(), v.end()); 103 99 for (int i = 0; i < test_len; ++i) { 104 check(v[i] == heap.prio() ,"Wrong order in heap sort.");100 check(v[i] == heap.prio() ,"Wrong order in heap sort."); 105 101 heap.pop(); 106 102 } … … 114 110 115 111 std::vector<int> v(test_len); 112 116 113 for (int i = 0; i < test_len; ++i) { 117 114 v[i] = test_seq[i]; … … 124 121 std::sort(v.begin(), v.end()); 125 122 for (int i = 0; i < test_len; ++i) { 126 check(v[i] == heap.prio() ,"Wrong order in heap increase test.");123 check(v[i] == heap.prio() ,"Wrong order in heap increase test."); 127 124 heap.pop(); 128 125 } 129 126 } 127 128 130 129 131 130 template <typename Heap> … … 143 142 if (dijkstra.reached(s)) { 144 143 check( dijkstra.dist(t) - dijkstra.dist(s) <= length[a], 145 "Error in shortest path tree.");144 "Error in a shortest path tree!"); 146 145 } 147 146 } … … 152 151 Node s = digraph.source(a); 153 152 check( dijkstra.dist(n) - dijkstra.dist(s) == length[a], 154 "Error in shortest path tree.");153 "Error in a shortest path tree!"); 155 154 } 156 155 } … … 174 173 run(); 175 174 176 // BinHeap177 175 { 178 176 typedef BinHeap<Prio, ItemIntMap> IntHeap; … … 186 184 } 187 185 188 // FouraryHeap189 {190 typedef FouraryHeap<Prio, ItemIntMap> IntHeap;191 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();192 heapSortTest<IntHeap>();193 heapIncreaseTest<IntHeap>();194 195 typedef FouraryHeap<Prio, IntNodeMap > NodeHeap;196 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();197 dijkstraHeapTest<NodeHeap>(digraph, length, source);198 }199 200 // KaryHeap201 {202 typedef KaryHeap<Prio, ItemIntMap> IntHeap;203 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();204 heapSortTest<IntHeap>();205 heapIncreaseTest<IntHeap>();206 207 typedef KaryHeap<Prio, IntNodeMap > NodeHeap;208 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();209 dijkstraHeapTest<NodeHeap>(digraph, length, source);210 }211 212 // FibHeap213 {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 // PairingHeap225 {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 // RadixHeap237 {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 // BinomHeap249 {250 typedef BinomHeap<Prio, ItemIntMap> IntHeap;251 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();252 heapSortTest<IntHeap>();253 heapIncreaseTest<IntHeap>();254 255 typedef BinomHeap<Prio, IntNodeMap > NodeHeap;256 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();257 dijkstraHeapTest<NodeHeap>(digraph, length, source);258 }259 260 // BucketHeap, SimpleBucketHeap261 {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>();273 }274 275 186 return 0; 276 187 }
Note: See TracChangeset
for help on using the changeset viewer.