Changeset 209:765619b7cbb2 in lemon-1.2 for test
- Timestamp:
- 07/13/08 20:51:02 (16 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- test
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
test/bfs_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 28 28 using namespace lemon; 29 29 30 void checkBfsCompile() 30 void checkBfsCompile() 31 31 { 32 32 typedef concepts::Digraph Digraph; 33 33 typedef Bfs<Digraph> BType; 34 34 35 35 Digraph G; 36 36 Digraph::Node n; … … 41 41 BType::PredMap p(G); 42 42 // BType::PredNodeMap pn(G); 43 43 44 44 BType bfs_test(G); 45 45 46 46 bfs_test.run(n); 47 47 48 48 l = bfs_test.dist(n); 49 49 e = bfs_test.predArc(n); … … 57 57 } 58 58 59 void checkBfsFunctionCompile() 59 void checkBfsFunctionCompile() 60 60 { 61 61 typedef int VType; … … 63 63 typedef Digraph::Arc Arc; 64 64 typedef Digraph::Node Node; 65 65 66 66 Digraph g; 67 67 bfs(g,Node()).run(); … … 82 82 Node s, t; 83 83 PetStruct<Digraph> ps = addPetersen(G, 5); 84 84 85 85 s=ps.outer[2]; 86 86 t=ps.inner[0]; 87 87 88 88 Bfs<Digraph> bfs_test(G); 89 89 bfs_test.run(s); 90 90 91 91 check(bfs_test.dist(t)==3,"Bfs found a wrong path." << bfs_test.dist(t)); 92 92 … … 96 96 check(pathSource(G, p) == s,"path() found a wrong path."); 97 97 check(pathTarget(G, p) == t,"path() found a wrong path."); 98 98 99 99 100 100 for(ArcIt e(G); e==INVALID; ++e) { … … 102 102 Node v=G.target(e); 103 103 check( !bfs_test.reached(u) || 104 105 104 (bfs_test.dist(v) > bfs_test.dist(u)+1), 105 "Wrong output."); 106 106 } 107 107 … … 113 113 check(u==bfs_test.predNode(v),"Wrong tree."); 114 114 check(bfs_test.dist(v) - bfs_test.dist(u) == 1, 115 "Wrong distance. Difference: " 116 << std::abs(bfs_test.dist(v) - bfs_test.dist(u) 117 115 "Wrong distance. Difference: " 116 << std::abs(bfs_test.dist(v) - bfs_test.dist(u) 117 - 1)); 118 118 } 119 119 } -
test/counter_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 76 76 void init(std::vector<int>& v) { 77 77 v[0] = 10; v[1] = 60; v[2] = 20; v[3] = 90; v[4] = 100; 78 v[5] = 80; v[6] = 40; v[7] = 30; v[8] = 50; v[9] = 70; 78 v[5] = 80; v[6] = 40; v[7] = 30; v[8] = 50; v[9] = 70; 79 79 } 80 80 … … 83 83 counterTest<Counter>(); 84 84 counterTest<NoCounter>(); 85 85 86 86 std::vector<int> x(10); 87 87 init(x); bubbleSort(x); -
test/dfs_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 28 28 using namespace lemon; 29 29 30 void checkDfsCompile() 30 void checkDfsCompile() 31 31 { 32 32 typedef concepts::Digraph Digraph; 33 33 typedef Dfs<Digraph> DType; 34 34 35 35 Digraph G; 36 36 Digraph::Node n; … … 41 41 DType::PredMap p(G); 42 42 // DType::PredNodeMap pn(G); 43 43 44 44 DType dfs_test(G); 45 45 46 46 dfs_test.run(n); 47 47 48 48 l = dfs_test.dist(n); 49 49 e = dfs_test.predArc(n); … … 57 57 } 58 58 59 void checkDfsFunctionCompile() 59 void checkDfsFunctionCompile() 60 60 { 61 61 typedef int VType; … … 63 63 typedef Digraph::Arc Arc; 64 64 typedef Digraph::Node Node; 65 65 66 66 Digraph g; 67 67 dfs(g,Node()).run(); … … 72 72 .reachedMap(concepts::ReadWriteMap<Node,bool>()) 73 73 .processedMap(concepts::WriteMap<Node,bool>()) 74 .run(Node()); 74 .run(Node()); 75 75 } 76 76 … … 82 82 Node s, t; 83 83 PetStruct<Digraph> ps = addPetersen(G, 5); 84 84 85 85 s=ps.outer[2]; 86 86 t=ps.inner[0]; 87 87 88 88 Dfs<Digraph> dfs_test(G); 89 dfs_test.run(s); 90 89 dfs_test.run(s); 90 91 91 Path<Digraph> p = dfs_test.path(t); 92 92 check(p.length() == dfs_test.dist(t),"path() found a wrong path."); … … 94 94 check(pathSource(G, p) == s,"path() found a wrong path."); 95 95 check(pathTarget(G, p) == t,"path() found a wrong path."); 96 96 97 97 for(NodeIt v(G); v!=INVALID; ++v) { 98 98 check(dfs_test.reached(v),"Each node should be reached."); … … 102 102 check(u==dfs_test.predNode(v),"Wrong tree."); 103 103 check(dfs_test.dist(v) - dfs_test.dist(u) == 1, 104 "Wrong distance. (" << dfs_test.dist(u) << "->" 105 104 "Wrong distance. (" << dfs_test.dist(u) << "->" 105 <<dfs_test.dist(v) << ')'); 106 106 } 107 107 } -
test/digraph_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 34 34 checkConcept<BaseDigraphComponent, BaseDigraphComponent >(); 35 35 36 checkConcept<IDableDigraphComponent<>, 36 checkConcept<IDableDigraphComponent<>, 37 37 IDableDigraphComponent<> >(); 38 38 39 checkConcept<IterableDigraphComponent<>, 39 checkConcept<IterableDigraphComponent<>, 40 40 IterableDigraphComponent<> >(); 41 41 42 checkConcept<MappableDigraphComponent<>, 42 checkConcept<MappableDigraphComponent<>, 43 43 MappableDigraphComponent<> >(); 44 44 } -
test/dijkstra_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 29 29 using namespace lemon; 30 30 31 void checkDijkstraCompile() 31 void checkDijkstraCompile() 32 32 { 33 33 typedef int VType; … … 35 35 typedef concepts::ReadMap<Digraph::Arc,VType> LengthMap; 36 36 typedef Dijkstra<Digraph, LengthMap> DType; 37 37 38 38 Digraph G; 39 39 Digraph::Node n; … … 61 61 } 62 62 63 void checkDijkstraFunctionCompile() 63 void checkDijkstraFunctionCompile() 64 64 { 65 65 typedef int VType; … … 68 68 typedef Digraph::Node Node; 69 69 typedef concepts::ReadMap<Digraph::Arc,VType> LengthMap; 70 70 71 71 Digraph g; 72 72 dijkstra(g,LengthMap(),Node()).run(); … … 79 79 80 80 template <class Digraph> 81 void checkDijkstra() { 81 void checkDijkstra() { 82 82 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 83 83 typedef typename Digraph::template ArcMap<int> LengthMap; … … 87 87 LengthMap length(G); 88 88 PetStruct<Digraph> ps = addPetersen(G, 5); 89 89 90 90 for(int i=0;i<5;i++) { 91 91 length[ps.outcir[i]]=4; … … 95 95 s=ps.outer[0]; 96 96 t=ps.inner[1]; 97 98 Dijkstra<Digraph, LengthMap> 99 97 98 Dijkstra<Digraph, LengthMap> 99 dijkstra_test(G, length); 100 100 dijkstra_test.run(s); 101 101 102 102 check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path."); 103 103 … … 107 107 check(pathSource(G, p) == s,"path() found a wrong path."); 108 108 check(pathTarget(G, p) == t,"path() found a wrong path."); 109 109 110 110 for(ArcIt e(G); e!=INVALID; ++e) { 111 111 Node u=G.source(e); 112 112 Node v=G.target(e); 113 113 check( !dijkstra_test.reached(u) || (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= length[e]), 114 114 "dist(target)-dist(source)-arc_length= " << dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]); 115 115 } 116 116 … … 122 122 check(u==dijkstra_test.predNode(v),"Wrong tree."); 123 123 check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == length[e], 124 124 "Wrong distance! Difference: " << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e])); 125 125 } 126 126 } 127 127 128 128 { 129 129 NullMap<Node,Arc> myPredMap; -
test/dim_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 -
test/error_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 59 59 60 60 static int cnt = 0; 61 void my_assert_handler(const char*, int, const char*, 62 61 void my_assert_handler(const char*, int, const char*, 62 const char*, const char*) { 63 63 ++cnt; 64 64 } -
test/graph_copy_test.cc
r200 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 123 123 } 124 124 } 125 125 126 126 ListGraph to; 127 127 ListGraph::NodeMap<int> tnm(to); … … 161 161 check(ecr[er[it]] == it, "Wrong copy."); 162 162 check(fem[it] == tem[er[it]], "Wrong copy."); 163 check(nr[from.u(it)] == to.u(er[it]) || nr[from.u(it)] == to.v(er[it]), 164 165 check(nr[from.v(it)] == to.u(er[it]) || nr[from.v(it)] == to.v(er[it]), 166 167 check((from.u(it) != from.v(it)) == (to.u(er[it]) != to.v(er[it])), 168 163 check(nr[from.u(it)] == to.u(er[it]) || nr[from.u(it)] == to.v(er[it]), 164 "Wrong copy."); 165 check(nr[from.v(it)] == to.u(er[it]) || nr[from.v(it)] == to.v(er[it]), 166 "Wrong copy."); 167 check((from.u(it) != from.v(it)) == (to.u(er[it]) != to.v(er[it])), 168 "Wrong copy."); 169 169 } 170 170 … … 189 189 graph_copy_test(); 190 190 191 return 0; 191 return 0; 192 192 } -
test/graph_maps_test.h
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 72 72 for (int i = 0; i < num; ++i) { 73 73 for (int j = 0; j < i; ++j) { 74 74 arcs.push_back(graph.addArc(nodes[i], nodes[j])); 75 75 } 76 76 } … … 85 85 for (int i = 0; i < num; ++i) { 86 86 for (int j = i + 1; j < num; ++j) { 87 88 87 arcs.push_back(graph.addArc(nodes[i], nodes[j])); 88 map[arcs.back()] = 23; 89 89 check(map[arcs.back()] == 23, "Wrong operator[]."); 90 90 } … … 114 114 for (int i = 0; i < num; ++i) { 115 115 for (int j = 0; j < i; ++j) { 116 116 edges.push_back(graph.addEdge(nodes[i], nodes[j])); 117 117 } 118 118 } … … 127 127 for (int i = 0; i < num; ++i) { 128 128 for (int j = i + 1; j < num; ++j) { 129 130 129 edges.push_back(graph.addEdge(nodes[i], nodes[j])); 130 map[edges.back()] = 23; 131 131 check(map[edges.back()] == 23, "Wrong operator[]."); 132 132 } -
test/graph_test.cc
r171 r209 1 /* -*- C++-*-2 * 3 * This file is a part of LEMON, a generic C++ optimization library 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 2003-2008 … … 34 34 checkConcept<BaseGraphComponent, BaseGraphComponent >(); 35 35 36 checkConcept<IDableGraphComponent<>, 36 checkConcept<IDableGraphComponent<>, 37 37 IDableGraphComponent<> >(); 38 38 39 checkConcept<IterableGraphComponent<>, 39 checkConcept<IterableGraphComponent<>, 40 40 IterableGraphComponent<> >(); 41 41 42 checkConcept<MappableGraphComponent<>, 42 checkConcept<MappableGraphComponent<>, 43 43 MappableGraphComponent<> >(); 44 44 } … … 135 135 // } 136 136 // } 137 137 138 138 // for (int i = 0; i < w; ++i) { 139 139 // for (int j = 0; j < h - 1; ++j) { … … 155 155 // for (int i = 0; i < w - 1; ++i) { 156 156 // check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right"); 157 // check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right"); 158 // } 159 // check(g.right(g(w - 1, j)) == INVALID, "Wrong right"); 157 // check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right"); 158 // } 159 // check(g.right(g(w - 1, j)) == INVALID, "Wrong right"); 160 160 // } 161 161 … … 163 163 // for (int i = 1; i < w; ++i) { 164 164 // check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left"); 165 // check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left"); 166 // } 167 // check(g.left(g(0, j)) == INVALID, "Wrong left"); 165 // check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left"); 166 // } 167 // check(g.left(g(0, j)) == INVALID, "Wrong left"); 168 168 // } 169 169 // } -
test/graph_test.h
r171 r209 1 /* -*- C++-*-2 * 3 * This file is a part of LEMON, a generic C++ optimization library 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 2003-2008 … … 218 218 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%num])); 219 219 } 220 220 221 221 return n; 222 222 } … … 247 247 checkBidirPetersen(G, num); 248 248 } 249 249 250 250 template <class Graph> 251 251 void checkGraph() { -
test/graph_utils_test.cc
r171 r209 1 /* -*- C++-*-2 * 3 * This file is a part of LEMON, a generic C++ optimization library 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 2003-2008 … … 141 141 { 142 142 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 143 143 144 144 const int nodeNum = 10; 145 145 const int arcNum = 100; … … 156 156 } 157 157 for (int i = 0; i < nodeNum; ++i) { 158 check(inDeg[nodes[i]] == countInArcs(digraph, nodes[i]), 158 check(inDeg[nodes[i]] == countInArcs(digraph, nodes[i]), 159 159 "Wrong in degree map"); 160 160 } 161 161 for (int i = 0; i < nodeNum; ++i) { 162 check(outDeg[nodes[i]] == countOutArcs(digraph, nodes[i]), 162 check(outDeg[nodes[i]] == countOutArcs(digraph, nodes[i]), 163 163 "Wrong out degree map"); 164 164 } … … 173 173 Node n1=g.addNode(); 174 174 Node n2=g.addNode(); 175 175 176 176 InDegMap<Digraph> ind(g); 177 177 178 178 g.addArc(n1,n2); 179 179 180 180 typename Digraph::Snapshot snap(g); 181 181 182 182 OutDegMap<Digraph> outd(g); 183 183 184 184 check(ind[n1]==0 && ind[n2]==1, "Wrong InDegMap value."); 185 185 check(outd[n1]==1 && outd[n2]==0, "Wrong OutDegMap value."); -
test/heap_test.cc
r203 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 41 41 DIGRAPH_TYPEDEFS(Digraph); 42 42 43 char test_lgf[] = 44 "@nodes\n" 45 "label\n" 46 "0\n" 47 "1\n" 48 "2\n" 49 "3\n" 50 "4\n" 51 "5\n" 52 "6\n" 53 "7\n" 54 "8\n" 55 "9\n" 56 "@arcs\n" 57 " label capacity\n"58 "0 5 0 94\n"59 "3 9 1 11\n"60 "8 7 2 83\n"61 "1 2 3 94\n"62 "5 7 4 35\n"63 "7 4 5 84\n"64 "9 5 6 38\n"65 "0 4 7 96\n"66 "6 7 8 6\n"67 "3 1 9 27\n"68 "5 2 10 77\n"69 "5 6 11 69\n"70 "6 5 12 41\n"71 "4 6 13 70\n"72 "3 2 14 45\n"73 "7 9 15 93\n"74 "5 9 16 50\n"75 "9 0 17 94\n"76 "9 6 18 67\n"77 "0 9 19 86\n"78 "@attributes\n" 43 char test_lgf[] = 44 "@nodes\n" 45 "label\n" 46 "0\n" 47 "1\n" 48 "2\n" 49 "3\n" 50 "4\n" 51 "5\n" 52 "6\n" 53 "7\n" 54 "8\n" 55 "9\n" 56 "@arcs\n" 57 " label capacity\n" 58 "0 5 0 94\n" 59 "3 9 1 11\n" 60 "8 7 2 83\n" 61 "1 2 3 94\n" 62 "5 7 4 35\n" 63 "7 4 5 84\n" 64 "9 5 6 38\n" 65 "0 4 7 96\n" 66 "6 7 8 6\n" 67 "3 1 9 27\n" 68 "5 2 10 77\n" 69 "5 6 11 69\n" 70 "6 5 12 41\n" 71 "4 6 13 70\n" 72 "3 2 14 45\n" 73 "7 9 15 93\n" 74 "5 9 16 50\n" 75 "9 0 17 94\n" 76 "9 6 18 67\n" 77 "0 9 19 86\n" 78 "@attributes\n" 79 79 "source 3\n"; 80 80 … … 89 89 90 90 Heap heap(map); 91 91 92 92 std::vector<int> v(test_len); 93 93 … … 108 108 109 109 Heap heap(map); 110 110 111 111 std::vector<int> v(test_len); 112 112 … … 129 129 130 130 template <typename Heap> 131 void dijkstraHeapTest(const Digraph& digraph, const IntArcMap& length, 132 133 131 void dijkstraHeapTest(const Digraph& digraph, const IntArcMap& length, 132 Node source) { 133 134 134 typename Dijkstra<Digraph, IntArcMap>::template DefStandardHeap<Heap>:: 135 135 Create dijkstra(digraph, length); … … 138 138 139 139 for(ArcIt a(digraph); a != INVALID; ++a) { 140 Node s = digraph.source(a); 140 Node s = digraph.source(a); 141 141 Node t = digraph.target(a); 142 142 if (dijkstra.reached(s)) { 143 143 check( dijkstra.dist(t) - dijkstra.dist(s) <= length[a], 144 144 "Error in a shortest path tree!"); 145 145 } 146 146 } … … 151 151 Node s = digraph.source(a); 152 152 check( dijkstra.dist(n) - dijkstra.dist(s) == length[a], 153 153 "Error in a shortest path tree!"); 154 154 } 155 155 } … … 162 162 typedef int Prio; 163 163 typedef RangeMap<int> ItemIntMap; 164 164 165 165 Digraph digraph; 166 166 IntArcMap length(digraph); … … 171 171 arcMap("capacity", length). 172 172 node("source", source). 173 run(); 174 173 run(); 174 175 175 { 176 176 typedef BinHeap<Prio, ItemIntMap> IntHeap; … … 178 178 heapSortTest<IntHeap>(); 179 179 heapIncreaseTest<IntHeap>(); 180 180 181 181 typedef BinHeap<Prio, IntNodeMap > NodeHeap; 182 182 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); -
test/kruskal_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 74 74 Node v4=G.addNode(); 75 75 Node t=G.addNode(); 76 76 77 77 Edge e1 = G.addEdge(s, v1); 78 78 Edge e2 = G.addEdge(s, v2); … … 91 91 ECostMap edge_cost_map(G, 2); 92 92 EBoolMap tree_map(G); 93 93 94 94 95 95 //Test with const map. 96 96 check(kruskal(G, ConstMap<ListGraph::Edge,int>(2), tree_map)==10, 97 97 "Total cost should be 10"); 98 98 //Test with an edge map (filled with uniform costs). 99 99 check(kruskal(G, edge_cost_map, tree_map)==10, 100 100 "Total cost should be 10"); 101 101 102 102 edge_cost_map.set(e1, -10); … … 115 115 //Test with a edge map and inserter. 116 116 check(kruskal(G, edge_cost_map, 117 118 119 120 117 tree_edge_vec.begin()) 118 ==-31, 119 "Total cost should be -31."); 120 121 121 tree_edge_vec.clear(); 122 122 123 123 check(kruskal(G, edge_cost_map, 124 125 126 127 124 back_inserter(tree_edge_vec)) 125 ==-31, 126 "Total cost should be -31."); 127 128 128 // tree_edge_vec.clear(); 129 129 130 130 // //The above test could also be coded like this: 131 131 // check(kruskal(G, 132 // 133 // 134 // 135 // 132 // makeKruskalMapInput(G, edge_cost_map), 133 // makeKruskalSequenceOutput(back_inserter(tree_edge_vec))) 134 // ==-31, 135 // "Total cost should be -31."); 136 136 137 137 check(tree_edge_vec.size()==5,"The tree should have 5 edges."); 138 138 139 139 check(tree_edge_vec[0]==e1 && 140 141 142 143 144 140 tree_edge_vec[1]==e2 && 141 tree_edge_vec[2]==e5 && 142 tree_edge_vec[3]==e7 && 143 tree_edge_vec[4]==e9, 144 "Wrong tree."); 145 145 146 146 return 0; -
test/maps_test.cc
r167 r209 1 /* -*- C++-*-2 * 3 * This file is a part of LEMON, a generic C++ optimization library 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 2003-2008 … … 305 305 "Something is wrong with EqualMap"); 306 306 } 307 307 308 308 // LoggerBoolMap 309 309 { … … 321 321 v1[0]==20 && v1[1]==50 && v1[2]==60 && v2[0]==20 && v2[1]==50 && v2[2]==60, 322 322 "Something is wrong with LoggerBoolMap"); 323 323 324 324 int i = 0; 325 325 for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin(); -
test/path_test.cc
r96 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 40 40 41 41 int main() { 42 check_concepts(); 42 check_concepts(); 43 43 return 0; 44 44 } -
test/random_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 34 34 35 35 lemon::rnd.seed(100); 36 lemon::rnd.seed(seed_array, seed_array + 37 36 lemon::rnd.seed(seed_array, seed_array + 37 (sizeof(seed_array) / sizeof(seed_array[0]))); 38 38 39 39 return 0; -
test/test_tools.h
r184 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 -
test/test_tools_fail.cc
r39 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 19 19 #include "test_tools.h" 20 20 21 int main() 21 int main() 22 22 { 23 23 check(false, "Don't panic. Failing is the right behaviour here."); -
test/test_tools_pass.cc
r39 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 19 19 #include "test_tools.h" 20 20 21 int main() 21 int main() 22 22 { 23 23 check(true, "It should pass."); -
test/time_measure_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 21 21 using namespace lemon; 22 22 23 void f() 23 void f() 24 24 { 25 25 double d=0; … … 28 28 } 29 29 30 void g() 30 void g() 31 31 { 32 32 static Timer T; 33 33 34 34 for(int i=0;i<1000;i++) 35 35 TimeStamp x(T); … … 50 50 std::cout << t << " (" << n << " tests)\n"; 51 51 std::cout << "Total: " << full << "\n"; 52 52 53 53 t=runningTimeTest(g,1,&n,&full); 54 54 std::cout << t << " (" << n << " tests)\n"; 55 55 std::cout << "Total: " << full << "\n"; 56 56 57 57 return 0; 58 58 } -
test/unionfind_test.cc
r171 r209 1 /* -*- C++-*-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 5 * Copyright (C) 2003-2008 … … 32 32 UFE U(base); 33 33 vector<ListGraph::Node> n; 34 34 35 35 for(int i=0;i<20;i++) n.push_back(g.addNode()); 36 36
Note: See TracChangeset
for help on using the changeset viewer.