[Lemon-commits] [lemon_svn] deba: r2067 - hugo/trunk/test

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:49:53 CET 2006


Author: deba
Date: Mon Jul 18 17:10:22 2005
New Revision: 2067

Modified:
   hugo/trunk/test/graph_utils_test.cc
   hugo/trunk/test/graph_utils_test.h
   hugo/trunk/test/undir_graph_test.cc

Log:
Improving tests.



Modified: hugo/trunk/test/graph_utils_test.cc
==============================================================================
--- hugo/trunk/test/graph_utils_test.cc	(original)
+++ hugo/trunk/test/graph_utils_test.cc	Mon Jul 18 17:10:22 2005
@@ -50,15 +50,26 @@
   ///\file
   { // checking list graph
     checkGraphCounters<ListGraph>();
+    checkFindEdge<ListGraph>();
   }
   { // checking smart graph
     checkGraphCounters<SmartGraph>();
+    checkFindEdge<SmartGraph>();
   }
   {
     int num = 5;
     FullGraph fg(num);
     check(countNodes(fg) == num, "FullGraph: wrong node number.");
-    check(countEdges(fg) == num*num, "FullGraph: wrong edge number.");    
+    check(countEdges(fg) == num*num, "FullGraph: wrong edge number.");
+    for (FullGraph::NodeIt src(fg); src != INVALID; ++src) {
+      for (FullGraph::NodeIt trg(fg); trg != INVALID; ++trg) {
+	ConEdgeIt<FullGraph> con(fg, src, trg);
+	check(con != INVALID, "There is no connecting edge.");
+	check(fg.source(con) == src, "Wrong source.");
+	check(fg.target(con) == trg, "Wrong target.");
+	check(++con == INVALID, "There is more connecting edge.");
+      }
+    }
   }
 
   //check In/OutDegMap (and SnapShot feature)

Modified: hugo/trunk/test/graph_utils_test.h
==============================================================================
--- hugo/trunk/test/graph_utils_test.h	(original)
+++ hugo/trunk/test/graph_utils_test.h	Mon Jul 18 17:10:22 2005
@@ -18,6 +18,8 @@
 
 
 #include "test_tools.h"
+#include <cstdlib>
+#include <ctime>
 
 //! \ingroup misc
 //! \file
@@ -37,6 +39,41 @@
       check(countInEdges(graph, it) == 3, "Wrong in degree number.");
     }
   }
+
+  template <typename Graph>
+  void checkFindEdge() {
+    typedef typename Graph::Node Node;
+    typedef typename Graph::Edge Edge;
+    typedef typename Graph::NodeIt NodeIt;
+    typedef typename Graph::EdgeIt EdgeIt;
+    Graph graph;
+    srand(time(0));
+    for (int i = 0; i < 10; ++i) {
+      graph.addNode();
+    }
+    DescriptorMap<Graph, Node> nodes(graph);
+    typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes);
+    for (int i = 0; i < 100; ++i) {
+      int src = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size());
+      int trg = (int)(rand() / (RAND_MAX + 1.0) * invNodes.size());
+      graph.addEdge(invNodes[src], invNodes[trg]);
+    }
+    typename Graph::template EdgeMap<bool> found(graph, false);
+    DescriptorMap<Graph, Edge> edges(graph);
+    for (NodeIt src(graph); src != INVALID; ++src) {
+      for (NodeIt trg(graph); trg != INVALID; ++trg) {
+	for (ConEdgeIt<Graph> con(graph, src, trg); con != INVALID; ++con) {
+	  check(graph.source(con) == src, "Wrong source.");
+	  check(graph.target(con) == trg, "Wrong target.");
+	  check(found[con] == false, "The edge found already.");
+	  found[con] = true;
+	}
+      }
+    }
+    for (EdgeIt it(graph); it != INVALID; ++it) {
+      check(found[it] == true, "The edge is not found.");
+    }
+  }
   
 } //namespace lemon
 

Modified: hugo/trunk/test/undir_graph_test.cc
==============================================================================
--- hugo/trunk/test/undir_graph_test.cc	(original)
+++ hugo/trunk/test/undir_graph_test.cc	Mon Jul 18 17:10:22 2005
@@ -40,6 +40,8 @@
   checkConcept<UndirGraph, UndirSmartGraph>();
   checkConcept<ExtendableUndirGraph, UndirSmartGraph>();
 
+  checkConcept<UndirGraph, UndirFullGraph>();
+
   checkConcept<UndirGraph, UndirGraph>();
 }
 
@@ -116,5 +118,10 @@
   check_graph<UndirListGraph>();
   check_graph<UndirSmartGraph>();
 
+  {
+    UndirFullGraph g(5);
+    check_item_counts(g, 5, 10);
+  }
+
   return 0;
 }



More information about the Lemon-commits mailing list