// Author: Douglas Gregor
#include <boost/graph/graphviz.hpp>
#include <boost/graph/adjacency_list.hpp>
-#include <boost/test/minimal.hpp>
+#include <boost/core/lightweight_test.hpp>
#include <string>
#include <fstream>
#include <boost/graph/iteration_macros.hpp>
void test_graph_read_write(const std::string& filename)
{
std::ifstream in(filename.c_str());
- BOOST_REQUIRE(in);
+ if (!BOOST_TEST(in)) {
+ return;
+ }
Graph g;
dynamic_properties dp;
dp.property("id", get(vertex_name, g));
dp.property("weight", get(edge_weight, g));
- BOOST_CHECK(read_graphviz(in, g, dp, "id"));
+ BOOST_TEST(read_graphviz(in, g, dp, "id"));
- BOOST_CHECK(num_vertices(g) == 4);
- BOOST_CHECK(num_edges(g) == 4);
+ BOOST_TEST(num_vertices(g) == 4);
+ BOOST_TEST(num_edges(g) == 4);
typedef graph_traits< Graph >::vertex_descriptor Vertex;
name_to_vertex[get(vertex_name, g, v)] = v;
// Check vertices
- BOOST_CHECK(name_to_vertex.find("0") != name_to_vertex.end());
- BOOST_CHECK(name_to_vertex.find("1") != name_to_vertex.end());
- BOOST_CHECK(name_to_vertex.find("foo") != name_to_vertex.end());
- BOOST_CHECK(name_to_vertex.find("bar") != name_to_vertex.end());
+ BOOST_TEST(name_to_vertex.find("0") != name_to_vertex.end());
+ BOOST_TEST(name_to_vertex.find("1") != name_to_vertex.end());
+ BOOST_TEST(name_to_vertex.find("foo") != name_to_vertex.end());
+ BOOST_TEST(name_to_vertex.find("bar") != name_to_vertex.end());
// Check edges
- BOOST_CHECK(edge(name_to_vertex["0"], name_to_vertex["1"], g).second);
- BOOST_CHECK(edge(name_to_vertex["1"], name_to_vertex["foo"], g).second);
- BOOST_CHECK(edge(name_to_vertex["foo"], name_to_vertex["bar"], g).second);
- BOOST_CHECK(edge(name_to_vertex["1"], name_to_vertex["bar"], g).second);
+ BOOST_TEST(edge(name_to_vertex["0"], name_to_vertex["1"], g).second);
+ BOOST_TEST(edge(name_to_vertex["1"], name_to_vertex["foo"], g).second);
+ BOOST_TEST(edge(name_to_vertex["foo"], name_to_vertex["bar"], g).second);
+ BOOST_TEST(edge(name_to_vertex["1"], name_to_vertex["bar"], g).second);
- BOOST_CHECK(get(edge_weight, g,
+ BOOST_TEST(get(edge_weight, g,
edge(name_to_vertex["0"], name_to_vertex["1"], g).first)
== 3.14159);
- BOOST_CHECK(get(edge_weight, g,
+ BOOST_TEST(get(edge_weight, g,
edge(name_to_vertex["1"], name_to_vertex["foo"], g).first)
== 2.71828);
- BOOST_CHECK(get(edge_weight, g,
+ BOOST_TEST(get(edge_weight, g,
edge(name_to_vertex["foo"], name_to_vertex["bar"], g).first)
== 10.0);
- BOOST_CHECK(get(edge_weight, g,
+ BOOST_TEST(get(edge_weight, g,
edge(name_to_vertex["1"], name_to_vertex["bar"], g).first)
== 10.0);
write_graphviz_dp(std::cout, g, dp, std::string("id"));
}
-int test_main(int argc, char* argv[])
+int main(int argc, char* argv[])
{
test_graph_read_write(argc >= 2 ? argv[1] : "graphviz_example.dot");
- return 0;
+ return boost::report_errors();
}