test_iteration.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // (C) Copyright 2009 Andrew Sutton
  2. //
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0 (See accompanying file
  5. // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef TEST_ITERATION_HPP
  7. #define TEST_ITERATION_HPP
  8. #include <boost/concept/assert.hpp>
  9. #include <algorithm>
  10. /** @name Test Vertex List
  11. * Test the vertex list interface. Note that there are currently no graphs that
  12. * do not expose this interface.
  13. */
  14. //@{
  15. template <typename Graph>
  16. void test_vertex_list_graph(Graph const& g) {
  17. using namespace boost;
  18. BOOST_CONCEPT_ASSERT((VertexListGraphConcept<Graph>));
  19. std::cout << "...test_vertex_list_graph\n";
  20. typedef typename graph_traits<Graph>::vertex_iterator Iterator;
  21. typedef std::pair<Iterator, Iterator> Range;
  22. Range rng = vertices(g);
  23. BOOST_ASSERT(num_vertices(g) == N);
  24. BOOST_ASSERT(rng.first != rng.second);
  25. BOOST_ASSERT(std::distance(rng.first, rng.second) == int(N));
  26. }
  27. //@}
  28. /** @name Test Edge List
  29. * Test the edge list interface. Note that there are currently no graphs that
  30. * do not expose this interface.
  31. */
  32. //@{
  33. template <typename Graph>
  34. void test_edge_list_graph(Graph const& g) {
  35. using namespace boost;
  36. BOOST_CONCEPT_ASSERT((EdgeListGraphConcept<Graph>));
  37. std::cout << "...test_edge_list_graph\n";
  38. typedef typename graph_traits<Graph>::edge_iterator Iterator;
  39. typedef std::pair<Iterator, Iterator> Range;
  40. Range rng = edges(g);
  41. BOOST_ASSERT(num_edges(g) == M);
  42. BOOST_ASSERT(rng.first != rng.second);
  43. BOOST_ASSERT(std::distance(rng.first, rng.second) == int(M));
  44. }
  45. //@}
  46. #endif