Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Boost.Assign usages. #416

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions test/graphviz_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#define BOOST_GRAPHVIZ_USE_ISTREAM
#include <boost/graph/graphviz.hpp>
#include <boost/assign/std/map.hpp>
#include <boost/assign.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/compressed_sparse_row_graph.hpp>
#include <boost/core/lightweight_test.hpp>
Expand All @@ -29,8 +27,6 @@ typedef float Mass;
typedef double Weight;
typedef std::map< node_t, Mass > expected_masses_t;
typedef std::map< edge_t, Weight > expected_weights_t;
#define MAP_MASSES boost::assign::list_of< std::pair< node_t, Mass > >
#define MAP_WEIGHTS boost::assign::list_of< std::pair< edge_t, Weight > >

struct Fixture
{
Expand All @@ -47,14 +43,14 @@ namespace Directed
static Fixture const basic {
"digraph { a node [mass = 7.7] c e [mass = 6.66] }",
3,
MAP_MASSES("a", 0.0f)("c", 7.7f)("e", 6.66f),
{ { "a", 0.0f }, { "c", 7.7f }, { "e", 6.66f } },
expected_weights_t(),
};

static Fixture const basic_aliased {
"digraph { a node [mass = 7.7] \"a\" e [mass = 6.66] }",
2,
MAP_MASSES("a", 0.0f)("e", 6.66f),
{ { "a", 0.0f }, { "e", 6.66f } },
expected_weights_t(),
};

Expand All @@ -64,9 +60,11 @@ namespace Directed
"d ->e->a [weight=.5]}",
6,
expected_masses_t(),
MAP_WEIGHTS(edge_t("a", "b"), 0.0)(edge_t("c", "d"), 7.7)(
edge_t("e", "f"), 6.66)(edge_t("d", "e"), 0.5)(
edge_t("e", "a"), 0.5),
{
{ edge_t("a", "b"), 0.0 }, { edge_t("c", "d"), 7.7 },
{ edge_t("e", "f"), 6.66 }, { edge_t("d", "e"), 0.5 },
{ edge_t("e", "a"), 0.5 } //
},
};
}

Expand All @@ -75,7 +73,7 @@ namespace Undirected
static Fixture const basic {
"graph { a nodE [mass = 7.7] c e [mass =\\\n6.66] }",
3,
MAP_MASSES("a", 0.0f)("c", 7.7f)("e", 6.66f),
{ { "a", 0.0f }, { "c", 7.7f }, { "e", 6.66f } },
expected_weights_t(),
};

Expand All @@ -84,8 +82,10 @@ namespace Undirected
"c -- d e -- f [weight = 6.66] }",
6,
expected_masses_t(),
MAP_WEIGHTS(edge_t("a", "b"), 0.0)(edge_t("c", "d"), 7.7)(
edge_t("e", "f"), 6.66),
{
{ edge_t("a", "b"), 0.0 }, { edge_t("c", "d"), 7.7 },
{ edge_t("e", "f"), 6.66 } //
},
};
}

Expand Down Expand Up @@ -331,7 +331,7 @@ void test_parallel_edges()
"diGraph { a -> b [weight = 7.7] a -> b [weight = 7.7] }",
2,
expected_masses_t(),
MAP_WEIGHTS(edge_t("a", "b"), 7.7),
{ { edge_t("a", "b"), 7.7 } },
};
TEST_GRAPH(Models::DiGraph, parallel);
BOOST_TEST_THROWS(TEST_GRAPH(Models::DiGraphNoParallel, parallel),
Expand All @@ -345,7 +345,7 @@ void test_graph_property_test_1()
"digraph { graph [name=\"foo \\\"escaped\\\"\"] a c e [mass = 6.66] "
"}",
3,
MAP_MASSES("a", 0.0f)("c", 0.0f)("e", 6.66f),
{ { "a", 0.0f }, { "c", 0.0f }, { "e", 6.66f } },
expected_weights_t(),
};
TEST_GRAPH(Models::DiGraph, named, "", "foo \"escaped\"");
Expand All @@ -357,7 +357,7 @@ void test_graph_property_test_2()
Fixture named {
"digraph { name=\"fo\"+ \"\\\no\" a c e [mass = 6.66] }",
3,
MAP_MASSES("a", 0.0f)("c", 0.0f)("e", 6.66f),
{ { "a", 0.0f }, { "c", 0.0f }, { "e", 6.66f } },
expected_weights_t(),
};
TEST_GRAPH(Models::DiGraph, named, "", "foo"); // SEHE why not "foo\no"?
Expand All @@ -372,7 +372,7 @@ void test_graph_property_test_3()
Fixture html_named {
"digraph { name=" + graph_name + " a c e [mass = 6.66] }",
3,
MAP_MASSES("a", 0.0f)("c", 0.0f)("e", 6.66f),
{ { "a", 0.0f }, { "c", 0.0f }, { "e", 6.66f } },
expected_weights_t(),
};
TEST_GRAPH(Models::DiGraph, html_named, "", graph_name);
Expand Down
56 changes: 16 additions & 40 deletions test/two_graphs_common_spanning_trees_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@
// Efficient Algorithm for Common Spanning Tree Problem
// Electron. Lett., 28 April 1983, Volume 19, Issue 9, p.346-347

#include <boost/type_traits.hpp>
#include <boost/concept/requires.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/compressed_pair.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/graph/two_graphs_common_spanning_trees.hpp>
#include <vector>

using namespace boost::assign;

namespace boost
{

Expand All @@ -32,14 +27,8 @@ typedef boost::adjacency_list< boost::vecS, // OutEdgeList
>
Graph;

typedef boost::graph_traits< Graph >::vertex_descriptor vertex_descriptor;

typedef boost::graph_traits< Graph >::edge_descriptor edge_descriptor;

typedef boost::graph_traits< Graph >::vertex_iterator vertex_iterator;

typedef boost::graph_traits< Graph >::edge_iterator edge_iterator;

template < typename Coll, typename Seq > struct check_edge
{
public:
Expand All @@ -56,16 +45,16 @@ template < typename Coll, typename Seq > struct check_edge
{
bool found = false;

for (typename Coll::iterator iterator = coll.begin();
!found && iterator != coll.end(); ++iterator)
for (auto iterator = coll.begin(); !found && iterator != coll.end();
++iterator)
{
Seq& coll_seq = *iterator;

BOOST_TEST(coll_seq.size() == seq.size());

found = true;
for (typename Seq::size_type pos = 0; found && pos < seq.size();
++pos)
++pos)
{
found &= coll_seq[pos] == seq[pos];
}
Expand All @@ -78,28 +67,17 @@ template < typename Coll, typename Seq > struct check_edge
void two_graphs_common_spanning_trees_test()
{
Graph iG, vG;
std::vector< edge_descriptor > iG_o;
std::vector< edge_descriptor > vG_o;

iG_o.push_back(boost::add_edge(0, 1, iG).first);
iG_o.push_back(boost::add_edge(1, 3, iG).first);
iG_o.push_back(boost::add_edge(3, 2, iG).first);
iG_o.push_back(boost::add_edge(1, 5, iG).first);
iG_o.push_back(boost::add_edge(5, 4, iG).first);
iG_o.push_back(boost::add_edge(5, 6, iG).first);
iG_o.push_back(boost::add_edge(5, 3, iG).first);
iG_o.push_back(boost::add_edge(3, 1, iG).first);
iG_o.push_back(boost::add_edge(1, 3, iG).first);

vG_o.push_back(boost::add_edge(0, 2, vG).first);
vG_o.push_back(boost::add_edge(0, 4, vG).first);
vG_o.push_back(boost::add_edge(0, 5, vG).first);
vG_o.push_back(boost::add_edge(5, 1, vG).first);
vG_o.push_back(boost::add_edge(5, 3, vG).first);
vG_o.push_back(boost::add_edge(5, 6, vG).first);
vG_o.push_back(boost::add_edge(5, 4, vG).first);
vG_o.push_back(boost::add_edge(5, 2, vG).first);
vG_o.push_back(boost::add_edge(2, 6, vG).first);
std::vector< edge_descriptor > iG_o { boost::add_edge(0, 1, iG).first,
boost::add_edge(1, 3, iG).first, boost::add_edge(3, 2, iG).first,
boost::add_edge(1, 5, iG).first, boost::add_edge(5, 4, iG).first,
boost::add_edge(5, 6, iG).first, boost::add_edge(5, 3, iG).first,
boost::add_edge(3, 1, iG).first, boost::add_edge(1, 3, iG).first };

std::vector< edge_descriptor > vG_o { boost::add_edge(0, 2, vG).first,
boost::add_edge(0, 4, vG).first, boost::add_edge(0, 5, vG).first,
boost::add_edge(5, 1, vG).first, boost::add_edge(5, 3, vG).first,
boost::add_edge(5, 6, vG).first, boost::add_edge(5, 4, vG).first,
boost::add_edge(5, 2, vG).first, boost::add_edge(2, 6, vG).first };

std::vector< std::vector< bool > > coll;
boost::tree_collector< std::vector< std::vector< bool > >,
Expand All @@ -113,12 +91,10 @@ void two_graphs_common_spanning_trees_test()
checker;
std::vector< bool > check;

check.clear();
check += true, true, true, true, true, true, false, false, false;
check.assign({ true, true, true, true, true, true, false, false, false });
checker(coll, check);

check.clear();
check += true, true, true, true, true, true, false, false, false;
check.assign({ true, true, true, true, true, true, false, false, false });
checker(coll, check);
}

Expand Down
Loading