summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/graph/test/test_iteration.hpp
blob: 3d6cb7078e3f0ef86082eb54bd644bef932a1504 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// (C) Copyright 2009 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)

#ifndef TEST_ITERATION_HPP
#define TEST_ITERATION_HPP

#include <boost/concept/assert.hpp>
#include <algorithm>

/** @name Test Vertex List
 * Test the vertex list interface. Note that there are currently no graphs that
 * do not expose this interface.
 */
//@{
template < typename Graph > void test_vertex_list_graph(Graph const& g)
{
    using namespace boost;
    BOOST_CONCEPT_ASSERT((VertexListGraphConcept< Graph >));

    std::cout << "...test_vertex_list_graph\n";
    typedef typename graph_traits< Graph >::vertex_iterator Iterator;
    typedef std::pair< Iterator, Iterator > Range;

    Range rng = vertices(g);
    BOOST_ASSERT(num_vertices(g) == N);
    BOOST_ASSERT(rng.first != rng.second);
    BOOST_ASSERT(std::distance(rng.first, rng.second) == int(N));
}
//@}

/** @name Test Edge List
 * Test the edge list interface. Note that there are currently no graphs that
 * do not expose this interface.
 */
//@{
template < typename Graph > void test_edge_list_graph(Graph const& g)
{
    using namespace boost;
    BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >));

    std::cout << "...test_edge_list_graph\n";
    typedef typename graph_traits< Graph >::edge_iterator Iterator;
    typedef std::pair< Iterator, Iterator > Range;

    Range rng = edges(g);
    BOOST_ASSERT(num_edges(g) == M);
    BOOST_ASSERT(rng.first != rng.second);
    BOOST_ASSERT(std::distance(rng.first, rng.second) == int(M));
}
//@}

#endif