LCOV - code coverage report
Current view: top level - trace/test - read_mcrl2.cpp (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 30 35 85.7 %
Date: 2020-02-28 00:44:21 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Unknown
       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 read_mcrl2.cpp
      10             : 
      11             : #define BOOST_TEST_MODULE read_mcrl2
      12             : 
      13             : #include <boost/test/included/unit_test_framework.hpp>
      14             : #include <exception>
      15             : 
      16             : #include "mcrl2/trace/trace.h"
      17             : 
      18             : using namespace std;
      19             : using namespace mcrl2;
      20             : using namespace mcrl2::trace;
      21             : 
      22             : 
      23           3 : void test_next_action(Trace& t, const char* s)
      24             : {
      25           6 :   mcrl2::lps::multi_action a = t.currentAction();
      26           3 :   t.increasePosition();
      27           3 :   BOOST_CHECK((a != mcrl2::lps::multi_action()));
      28           3 :   if (a != mcrl2::lps::multi_action())
      29             :   {
      30           6 :     string action(pp(a));
      31           3 :     BOOST_CHECK(action == s);
      32           3 :     if (action != s)
      33             :     {
      34           0 :       std::cout << "--- error detected ---\n";
      35           0 :       std::cout << "result         : " << action << std::endl;
      36           0 :       std::cout << "expected result: " << s << std::endl;
      37             :     }
      38             :   }
      39           3 : }
      40             : 
      41           3 : BOOST_AUTO_TEST_CASE(test_main)
      42             : {
      43             :   using namespace mcrl2::data;
      44             :   using namespace mcrl2::lps;
      45             :   using namespace mcrl2::core;
      46           2 :   mcrl2::data::data_specification data_spec;
      47           2 :   process::action_label_list act_decls;
      48           1 :   act_decls.push_front(process::action_label(identifier_string("a"),sort_expression_list()));
      49           2 :   sort_expression_list s;
      50           1 :   s.push_front(sort_bool::bool_());
      51           1 :   s.push_front(sort_pos::pos());
      52           1 :   act_decls.push_front(process::action_label("b",s));
      53           1 :   act_decls.push_front(process::action_label(identifier_string("c"),sort_expression_list()));
      54             : 
      55           2 :   Trace t(data_spec, act_decls);
      56           1 :   t.addAction(parse_multi_action("a",act_decls,data_spec));
      57           1 :   t.addAction(parse_multi_action("b(1,true)",act_decls,data_spec));
      58           1 :   t.addAction(parse_multi_action("c",act_decls,data_spec));
      59             : 
      60           2 :   stringstream trace_data;
      61           1 :   t.save(trace_data);
      62             : 
      63             :   try
      64             :   {
      65           1 :     t.load(trace_data,tfMcrl2);
      66             :   }
      67           0 :   catch (const mcrl2::runtime_error& e)
      68             :   {
      69           0 :     BOOST_ERROR(e.what());
      70             :   }
      71             : 
      72           1 :   BOOST_CHECK(t.number_of_actions() == 3);
      73             : 
      74           1 :   test_next_action(t,"a");
      75           1 :   test_next_action(t,"b(1, true)");
      76           1 :   test_next_action(t,"c");
      77           4 : }

Generated by: LCOV version 1.13