Improving tests.
1.1 --- a/test/graph_utils_test.cc Mon Jul 18 15:09:37 2005 +0000
1.2 +++ b/test/graph_utils_test.cc Mon Jul 18 15:10:22 2005 +0000
1.3 @@ -50,15 +50,26 @@
1.4 ///\file
1.5 { // checking list graph
1.6 checkGraphCounters<ListGraph>();
1.7 + checkFindEdge<ListGraph>();
1.8 }
1.9 { // checking smart graph
1.10 checkGraphCounters<SmartGraph>();
1.11 + checkFindEdge<SmartGraph>();
1.12 }
1.13 {
1.14 int num = 5;
1.15 FullGraph fg(num);
1.16 check(countNodes(fg) == num, "FullGraph: wrong node number.");
1.17 - check(countEdges(fg) == num*num, "FullGraph: wrong edge number.");
1.18 + check(countEdges(fg) == num*num, "FullGraph: wrong edge number.");
1.19 + for (FullGraph::NodeIt src(fg); src != INVALID; ++src) {
1.20 + for (FullGraph::NodeIt trg(fg); trg != INVALID; ++trg) {
1.21 + ConEdgeIt<FullGraph> con(fg, src, trg);
1.22 + check(con != INVALID, "There is no connecting edge.");
1.23 + check(fg.source(con) == src, "Wrong source.");
1.24 + check(fg.target(con) == trg, "Wrong target.");
1.25 + check(++con == INVALID, "There is more connecting edge.");
1.26 + }
1.27 + }
1.28 }
1.29
1.30 //check In/OutDegMap (and SnapShot feature)
2.1 --- a/test/graph_utils_test.h Mon Jul 18 15:09:37 2005 +0000
2.2 +++ b/test/graph_utils_test.h Mon Jul 18 15:10:22 2005 +0000
2.3 @@ -18,6 +18,8 @@
2.4
2.5
2.6 #include "test_tools.h"
2.7 +#include <cstdlib>
2.8 +#include <ctime>
2.9
2.10 //! \ingroup misc
2.11 //! \file
2.12 @@ -37,6 +39,41 @@
2.13 check(countInEdges(graph, it) == 3, "Wrong in degree number.");
2.14 }
2.15 }
2.16 +
2.17 + template <typename Graph>
2.18 + void checkFindEdge() {
2.19 + typedef typename Graph::Node Node;
2.20 + typedef typename Graph::Edge Edge;
2.21 + typedef typename Graph::NodeIt NodeIt;
2.22 + typedef typename Graph::EdgeIt EdgeIt;
2.23 + Graph graph;
2.24 + srand(time(0));
2.25 + for (int i = 0; i < 10; ++i) {
2.26 + graph.addNode();
2.27 + }
2.28 + DescriptorMap<Graph, Node> nodes(graph);
2.29 + typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes);
2.30 + for (int i = 0; i < 100; ++i) {
2.31 + int src = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size());
2.32 + int trg = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size());
2.33 + graph.addEdge(invNodes[src], invNodes[trg]);
2.34 + }
2.35 + typename Graph::template EdgeMap<bool> found(graph, false);
2.36 + DescriptorMap<Graph, Edge> edges(graph);
2.37 + for (NodeIt src(graph); src != INVALID; ++src) {
2.38 + for (NodeIt trg(graph); trg != INVALID; ++trg) {
2.39 + for (ConEdgeIt<Graph> con(graph, src, trg); con != INVALID; ++con) {
2.40 + check(graph.source(con) == src, "Wrong source.");
2.41 + check(graph.target(con) == trg, "Wrong target.");
2.42 + check(found[con] == false, "The edge found already.");
2.43 + found[con] = true;
2.44 + }
2.45 + }
2.46 + }
2.47 + for (EdgeIt it(graph); it != INVALID; ++it) {
2.48 + check(found[it] == true, "The edge is not found.");
2.49 + }
2.50 + }
2.51
2.52 } //namespace lemon
2.53
3.1 --- a/test/undir_graph_test.cc Mon Jul 18 15:09:37 2005 +0000
3.2 +++ b/test/undir_graph_test.cc Mon Jul 18 15:10:22 2005 +0000
3.3 @@ -40,6 +40,8 @@
3.4 checkConcept<UndirGraph, UndirSmartGraph>();
3.5 checkConcept<ExtendableUndirGraph, UndirSmartGraph>();
3.6
3.7 + checkConcept<UndirGraph, UndirFullGraph>();
3.8 +
3.9 checkConcept<UndirGraph, UndirGraph>();
3.10 }
3.11
3.12 @@ -116,5 +118,10 @@
3.13 check_graph<UndirListGraph>();
3.14 check_graph<UndirSmartGraph>();
3.15
3.16 + {
3.17 + UndirFullGraph g(5);
3.18 + check_item_counts(g, 5, 10);
3.19 + }
3.20 +
3.21 return 0;
3.22 }