Line data Source code
1 : // Author(s): Wieger Wesselink 2 : // Copyright: see the accompanying file COPYING or copy at 3 : // https://github.com/mCRL2org/mCRL2/blob/master/COPYING 4 : // 5 : // Distributed under the Boost Software License, Version 1.0. 6 : // (See accompanying file LICENSE_1_0.txt or copy at 7 : // http://www.boost.org/LICENSE_1_0.txt) 8 : // 9 : 10 : #include "mcrl2/utilities/reachable_nodes.h" 11 : 12 : #define BOOST_AUTO_TEST_MAIN 13 : #include <boost/test/included/unit_test.hpp> 14 : 15 : using namespace mcrl2::utilities; 16 : 17 1 : void test_reachable_nodes() 18 : { 19 : typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> graph; 20 : 21 1 : graph g(6); 22 1 : boost::add_edge(0, 1, g); 23 1 : boost::add_edge(0, 2, g); 24 1 : boost::add_edge(1, 2, g); 25 1 : boost::add_edge(2, 4, g); 26 1 : boost::add_edge(3, 2, g); 27 1 : boost::add_edge(3, 5, g); 28 : 29 1 : std::vector<std::size_t> v; 30 1 : v.push_back(1); 31 1 : v.push_back(5); 32 : 33 1 : std::vector<std::size_t> nodes = reachable_nodes(g, v.begin(), v.end()); 34 1 : BOOST_CHECK(nodes.size() == 4); 35 1 : BOOST_CHECK(std::find(nodes.begin(), nodes.end(), 1) != nodes.end()); 36 1 : BOOST_CHECK(std::find(nodes.begin(), nodes.end(), 2) != nodes.end()); 37 1 : BOOST_CHECK(std::find(nodes.begin(), nodes.end(), 4) != nodes.end()); 38 1 : BOOST_CHECK(std::find(nodes.begin(), nodes.end(), 5) != nodes.end()); 39 1 : } 40 : 41 2 : BOOST_AUTO_TEST_CASE(test_main) 42 : { 43 1 : test_reachable_nodes(); 44 1 : }