File: reachable_nodes_test.cpp

package info (click to toggle)
mcrl2 201409.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd
  • size: 46,348 kB
  • ctags: 29,960
  • sloc: cpp: 213,160; ansic: 16,219; python: 13,238; yacc: 309; lex: 214; xml: 197; makefile: 83; sh: 82; pascal: 17
file content (39 lines) | stat: -rwxr-xr-x 1,175 bytes parent folder | download | duplicates (2)
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
#include <boost/test/minimal.hpp>
// Copyright: see the accompanying file COPYING or copy at
// https://svn.win.tue.nl/trac/MCRL2/browser/trunk/COPYING
#include <boost/graph/adjacency_list.hpp>
#include "mcrl2/utilities/reachable_nodes.h"

using namespace mcrl2::utilities;

void test_reachable_nodes()
{
  typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> graph;
  typedef boost::graph_traits<graph>::vertex_descriptor vertex_descriptor;

  graph g(6);
  boost::add_edge(0, 1, g);
  boost::add_edge(0, 2, g);
  boost::add_edge(1, 2, g);
  boost::add_edge(2, 4, g);
  boost::add_edge(3, 2, g);
  boost::add_edge(3, 5, g);

  std::vector<size_t> v;
  v.push_back(1);
  v.push_back(5);

  std::vector<size_t> nodes = reachable_nodes(g, v.begin(), v.end());
  BOOST_CHECK(nodes.size() == 4);
  BOOST_CHECK(std::find(nodes.begin(), nodes.end(), 1) != nodes.end());
  BOOST_CHECK(std::find(nodes.begin(), nodes.end(), 2) != nodes.end());
  BOOST_CHECK(std::find(nodes.begin(), nodes.end(), 4) != nodes.end());
  BOOST_CHECK(std::find(nodes.begin(), nodes.end(), 5) != nodes.end());
}

int test_main(int, char*[])
{
  test_reachable_nodes();

  return 0;
}