|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53134 - trunk/libs/graph/test
From: asutton_at_[hidden]
Date: 2009-05-20 12:06:16
Author: asutton
Date: 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
New Revision: 53134
URL: http://svn.boost.org/trac/boost/changeset/53134
Log:
Added a test to verify a bug from Dmitry Bufistov. Built in some output to
help debug the graph testing framework.
Added:
trunk/libs/graph/test/read_propmap.cpp (contents, props changed)
Text files modified:
trunk/libs/graph/test/Jamfile.v2 | 1 +
trunk/libs/graph/test/test_construction.hpp | 4 ++++
trunk/libs/graph/test/test_destruction.hpp | 4 ++++
trunk/libs/graph/test/test_direction.hpp | 3 +++
trunk/libs/graph/test/test_graph.hpp | 2 ++
trunk/libs/graph/test/test_graphs.cpp | 9 +++++++++
trunk/libs/graph/test/test_iteration.hpp | 2 ++
trunk/libs/graph/test/test_properties.hpp | 2 ++
8 files changed, 27 insertions(+), 0 deletions(-)
Modified: trunk/libs/graph/test/Jamfile.v2
==============================================================================
--- trunk/libs/graph/test/Jamfile.v2 (original)
+++ trunk/libs/graph/test/Jamfile.v2 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -112,6 +112,7 @@
[ run eccentricity.cpp ]
[ run clustering_coefficient.cpp ]
[ run core_numbers_test.cpp ]
+ [ run read_propmap.cpp ]
$(optional_tests)
;
Added: trunk/libs/graph/test/read_propmap.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/graph/test/read_propmap.cpp 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -0,0 +1,30 @@
+// (C) Copyright 2009 Dmitry Bufistov, Andrew Sutton
+//
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0 (See accompanying file
+// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/graph/graph_concepts.hpp>
+#include <boost/graph/adjacency_list.hpp>
+
+// Test contributed by Dmitry that validates a read-only property map bug
+// for bundled properties.
+// TODO: Integrate this into a testing framework.
+
+using namespace boost;
+
+struct EdgeProp
+{
+ double weight;
+};
+
+typedef adjacency_list<vecS, vecS, directedS, no_property, EdgeProp > graph_t;
+int main()
+{
+ typedef property_map<graph_t, double EdgeProp::*>::type WeightMap;
+ typedef property_map<graph_t, double EdgeProp::*>::const_type cWeightMap;
+ typedef graph_traits<graph_t>::edge_descriptor Edge;
+ function_requires<ReadablePropertyMapConcept<WeightMap, Edge> >();
+ function_requires<ReadablePropertyMapConcept<cWeightMap, Edge> >();
+ return 0;
+}
Modified: trunk/libs/graph/test/test_construction.hpp
==============================================================================
--- trunk/libs/graph/test/test_construction.hpp (original)
+++ trunk/libs/graph/test/test_construction.hpp 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -24,6 +24,7 @@
// This matches MutableGraph, so just add some vertices.
template <typename Graph>
void build_graph(Graph& g, boost::mpl::true_, boost::mpl::false_) {
+ std::cout << "...build_normal\n";
for(std::size_t i = 0; i < N; ++i) {
boost::add_vertex(g);
}
@@ -32,6 +33,7 @@
// This will match labeled graphs.
template <typename Graph>
void build_graph(Graph& g, boost::mpl::false_, boost::mpl::true_) {
+ std::cout << "...build_labeled\n";
// Add each vertex labeled with the number i.
for(std::size_t i = 0; i < N; ++i) {
boost::add_vertex(i, g);
@@ -50,6 +52,7 @@
//@{
template <typename Graph, typename VertexSet>
void connect_graph(Graph& g, VertexSet const& verts, boost::mpl::false_) {
+ std::cout << "...connect_normal\n";
Pair *f, *l;
for(boost::tie(f, l) = edge_pairs(); f != l; ++f) {
Pair const& e = *f;
@@ -63,6 +66,7 @@
template <typename Graph, typename VertexSet>
void connect_graph(Graph& g, VertexSet const& verts, boost::mpl::true_) {
+ std::cout << "...connect_labeled\n";
// With labeled graphs, we want to operate directly on the edge numbers
// rather than looking up the correct vertex index. This is because the
// vertices are already mapped to indices.
Modified: trunk/libs/graph/test/test_destruction.hpp
==============================================================================
--- trunk/libs/graph/test/test_destruction.hpp (original)
+++ trunk/libs/graph/test/test_destruction.hpp 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -21,6 +21,7 @@
// This matches MutableGraph, so just remove a vertex and then clear.
template <typename Graph, typename VertexSet>
void destroy_graph(Graph& g, VertexSet const& verts, boost::mpl::true_, boost::mpl::false_) {
+ std::cout << "...destroy_normal\n";
// Remove the roof vertex
boost::remove_vertex(verts[0], g);
BOOST_ASSERT(boost::num_vertices(g) == N - 1);
@@ -29,6 +30,7 @@
// This will match labeled graphs.
template <typename Graph, typename VertexSet>
void destroy_graph(Graph& g, VertexSet const& verts, boost::mpl::false_, boost::mpl::true_) {
+ std::cout << "...destroy_labeled\n";
// Remove the roof vertex
boost::remove_vertex(0, g);
BOOST_ASSERT(boost::num_vertices(g) == N - 1);
@@ -48,6 +50,7 @@
template <typename Graph, typename VertexSet>
void disconnect_graph(Graph& g, VertexSet const& verts, boost::mpl::false_) {
+ std::cout << "...disconnect_normal\n";
typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
// Disconnect the "lollipop" from the house.
@@ -70,6 +73,7 @@
template <typename Graph, typename VertexSet>
void disconnect_graph(Graph& g, VertexSet const& verts, boost::mpl::true_) {
+ std::cout << "...disconnect_labeled\n";
typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
// Disconnect the "lollipop" from the house.
Modified: trunk/libs/graph/test/test_direction.hpp
==============================================================================
--- trunk/libs/graph/test/test_direction.hpp (original)
+++ trunk/libs/graph/test/test_direction.hpp 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -16,6 +16,7 @@
//@{
template <typename Graph, typename VertexSet>
void test_outdirected_graph(Graph const& g, VertexSet const& verts, boost::mpl::true_) {
+ std::cout << "...test_outdirected_graph\n";
typedef typename boost::graph_traits<Graph>::out_edge_iterator OutIter;
typedef std::pair<OutIter, OutIter> OutRange;
typedef std::vector<OutRange> OutSet;
@@ -55,6 +56,7 @@
//@{
template <typename Graph, typename VertexSet>
void test_indirected_graph(Graph const& g, VertexSet const& verts, boost::mpl::true_) {
+ std::cout << "...test_indirected_graph\n";
typedef typename boost::graph_traits<Graph>::in_edge_iterator InIter;
typedef std::pair<InIter, InIter> InRange;
typedef std::vector<InRange> InSet;
@@ -89,6 +91,7 @@
*/
template <typename Graph, typename VertexSet>
void test_undirected_graph(Graph const& g, VertexSet const& verts, boost::mpl::true_) {
+ std::cout << "...test_undirected_graph\n";
typedef typename boost::graph_traits<Graph>::out_edge_iterator OutIter;
typedef std::pair<OutIter, OutIter> OutRange;
typedef std::vector<OutRange> OutSet;
Modified: trunk/libs/graph/test/test_graph.hpp
==============================================================================
--- trunk/libs/graph/test/test_graph.hpp (original)
+++ trunk/libs/graph/test/test_graph.hpp 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -87,6 +87,8 @@
template <typename Graph>
void test_graph(Graph& g) {
+ std::cout << typestr(g) << "\n";
+
// Define a bunch of tags for the graph.
typename boost::graph_has_add_vertex<Graph>::type can_add_vertex;
typename boost::graph_has_remove_vertex<Graph>::type can_remove_vertex;
Modified: trunk/libs/graph/test/test_graphs.cpp
==============================================================================
--- trunk/libs/graph/test/test_graphs.cpp (original)
+++ trunk/libs/graph/test/test_graphs.cpp 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -13,6 +13,7 @@
#include <boost/graph/undirected_graph.hpp>
#include <boost/graph/directed_graph.hpp>
#include <boost/graph/labeled_graph.hpp>
+#include <boost/graph/subgraph.hpp>
#include "test_graph.hpp"
@@ -148,5 +149,13 @@
Graph g;
test_graph(g);
}
+ {
+ // Make srue that subgraph obeys the basi
+ typedef property<edge_index_t, size_t, EdgeBundle> EdgeProp;
+ typedef adjacency_list<vecS, vecS, directedS, VertexBundle, EdgeProp> BaseGraph;
+ typedef subgraph<BaseGraph> Graph;
+ Graph g;
+ test_graph(g);
+ }
}
Modified: trunk/libs/graph/test/test_iteration.hpp
==============================================================================
--- trunk/libs/graph/test/test_iteration.hpp (original)
+++ trunk/libs/graph/test/test_iteration.hpp 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -16,6 +16,7 @@
//@{
template <typename Graph>
void test_vertex_list_graph(Graph const& g) {
+ std::cout << "...test_vertex_list_graph\n";
typedef typename boost::graph_traits<Graph>::vertex_iterator Iterator;
typedef std::pair<Iterator, Iterator> Range;
@@ -33,6 +34,7 @@
//@{
template <typename Graph>
void test_edge_list_graph(Graph const& g) {
+ std::cout << "...test_edge_list_graph\n";
typedef typename boost::graph_traits<Graph>::edge_iterator Iterator;
typedef std::pair<Iterator, Iterator> Range;
Modified: trunk/libs/graph/test/test_properties.hpp
==============================================================================
--- trunk/libs/graph/test/test_properties.hpp (original)
+++ trunk/libs/graph/test/test_properties.hpp 2009-05-20 12:06:13 EDT (Wed, 20 May 2009)
@@ -14,6 +14,7 @@
//@{
template <typename Graph, typename VertexSet>
void test_vertex_bundle(Graph& g, VertexSet const& verts, boost::mpl::true_) {
+ std::cout << "...test_vertex_bundle\n";
typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
// This just has to compile. You can't actually get this map.
@@ -44,6 +45,7 @@
//@{
template <typename Graph, typename VertexSet>
void test_edge_bundle(Graph& g, VertexSet const& verts, boost::mpl::true_) {
+ std::cout << "...test_edge_bundle\n";
// This just has to compile. You can't actually get this map.
typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
typedef typename boost::property_map<Graph, boost::edge_bundle_t>::type TestMap;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk