2
0
mirror of https://github.com/boostorg/graph.git synced 2026-02-25 16:32:09 +00:00

Merge pull request #5 from BenPope/develop

Fix [un]directed_graph::swap and add tests

Nice job, thanks!  I'll have to look at your other points a bit more carefully before responding.
This commit is contained in:
Noel Belcourt
2014-05-14 10:41:25 -06:00
4 changed files with 24 additions and 2 deletions

View File

@@ -307,7 +307,7 @@ public:
void swap(directed_graph& g)
{
m_graph.swap(g);
m_graph.swap(g.m_graph);
std::swap(m_num_vertices, g.m_num_vertices);
std::swap(m_max_vertex_index, g.m_max_vertex_index);
std::swap(m_num_edges, g.m_num_edges);

View File

@@ -294,7 +294,7 @@ public:
}
void swap(undirected_graph& g) {
m_graph.swap(g);
m_graph.swap(g.m_graph);
std::swap(m_num_vertices, g.m_num_vertices);
std::swap(m_max_vertex_index, g.m_max_vertex_index);
std::swap(m_num_edges, g.m_num_edges);

View File

@@ -79,6 +79,7 @@ test-suite graph_test :
[ run adjacency_matrix_test.cpp ]
[ compile vector_graph_cc.cpp ]
[ compile copy.cpp ]
[ compile swap.cpp ]
[ compile property_iter.cpp ]
[ run bundled_properties.cpp ]
[ run floyd_warshall_test.cpp ]

21
test/swap.cpp Normal file
View File

@@ -0,0 +1,21 @@
// Copyright (C) Ben Pope 2014.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/graph/directed_graph.hpp>
#include <boost/graph/undirected_graph.hpp>
template<typename Graph>
void test_member_swap()
{
Graph lhs, rhs;
lhs.swap(rhs);
}
int main()
{
test_member_swap<boost::adjacency_list<> >();
test_member_swap<boost::directed_graph<> >();
test_member_swap<boost::undirected_graph<> >();
}