LCOV - code coverage report
Current view: top level - bes/test - bes_io_test.cpp (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 38 38 100.0 %
Date: 2019-09-14 00:54:39 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          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             : /// \file bes_io_test.cpp
      10             : /// \brief Some io tests for boolean equation systems.
      11             : 
      12             : #define BOOST_TEST_MODULE bes_io_test
      13             : #include <sstream>
      14             : #include <string>
      15             : #include <boost/test/included/unit_test_framework.hpp>
      16             : #include "mcrl2/bes/boolean_equation_system.h"
      17             : #include "mcrl2/bes/io.h"
      18             : #include "mcrl2/bes/parse.h"
      19             : #include "mcrl2/bes/print.h"
      20             : #include "mcrl2/pbes/pbes.h"
      21             : #include "mcrl2/bes/pbesinst_conversion.h"
      22             : 
      23             : using namespace mcrl2;
      24             : using namespace mcrl2::bes;
      25             : 
      26           1 : std::string bes1 =
      27             :   "pbes              \n"
      28             :   "                  \n"
      29             :   "nu X1 = X2 && X1; \n"
      30             :   "mu X2 = X1 || X2; \n"
      31             :   "                  \n"
      32             :   "init X1;          \n"
      33             :   ;
      34             : 
      35           1 : void test_parse_bes()
      36             : {
      37           2 :   boolean_equation_system b;
      38           2 :   std::stringstream from(bes1);
      39           1 :   from >> b;
      40           1 :   std::cout << "b = \n" << bes::pp(b) << std::endl;
      41             : 
      42             :   // check if the pretty printed BES can be parsed again
      43           2 :   std::string bes2 = bes::pp(b);
      44           2 :   std::stringstream from2(bes1);
      45           1 :   from2 >> b;
      46             : 
      47           1 : }
      48             : 
      49           1 : void test_bes()
      50             : {
      51           2 :   boolean_equation_system b;
      52           2 :   std::stringstream bes_stream(bes1);
      53           1 :   bes_stream >> b;
      54             : 
      55           2 :   std::stringstream out;
      56           1 :   bes::save_bes(b, out, bes_format_internal());
      57           1 : }
      58             : 
      59           1 : void test_pbes()
      60             : {
      61           2 :   pbes_system::pbes b;
      62           2 :   std::stringstream bes_stream(bes1);
      63           1 :   bes_stream >> b;
      64             : 
      65           2 :   std::stringstream out;
      66           1 :   bes::save_pbes(b, out, bes_format_internal());
      67           1 : }
      68             : 
      69           1 : void test_pgsolver()
      70             : {
      71           2 :   boolean_equation_system b;
      72           2 :   std::stringstream bes_stream(bes1);
      73           1 :   bes_stream >> b;
      74             : 
      75           2 :   std::stringstream out;
      76           1 :   bes::save_bes_pgsolver(b, out);
      77             : 
      78           1 :   std::clog << out.str() << std::endl;
      79           1 : }
      80             : 
      81           3 : BOOST_AUTO_TEST_CASE(test_main)
      82             : {
      83           1 :   test_parse_bes();
      84           1 :   test_bes();
      85           1 :   test_pbes();
      86           1 :   test_pgsolver();
      87           4 : }

Generated by: LCOV version 1.12