LCOV - code coverage report
Current view: top level - trace/test - read_plain.cpp (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 20 22 90.9 %
Date: 2020-02-28 00:44:21 Functions: 6 6 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_plain.cpp
      10             : 
      11             : #define BOOST_TEST_MODULE read_plain
      12             : #include <boost/test/included/unit_test_framework.hpp>
      13             : 
      14             : #include "mcrl2/trace/trace.h"
      15             : 
      16             : using namespace std;
      17             : using namespace mcrl2::trace;
      18             : 
      19             : static const char* trace_str = "a\nb(1,true)\nc\n";
      20             : 
      21           1 : static bool read_trace(Trace& t, const char* s)
      22             : {
      23           2 :   stringstream ss(s);
      24             : 
      25             :   try
      26             :   {
      27           1 :     t.load(ss);
      28             :   }
      29           0 :   catch (...)
      30             :   {
      31           0 :     return false;
      32             :   }
      33             : 
      34           1 :   return true;
      35             : }
      36             : 
      37           3 : void test_next_action(Trace& t, const char* s)
      38             : {
      39           6 :   mcrl2::lps::multi_action a = t.currentAction();
      40           3 :   t.increasePosition();
      41           3 :   BOOST_CHECK(a != mcrl2::lps::multi_action());
      42           3 :   if (a != mcrl2::lps::multi_action())
      43             :   {
      44           3 :     BOOST_CHECK(a.actions().size() == 1);
      45           3 :     BOOST_CHECK(pp(a)==s);
      46             :   }
      47           3 : }
      48             : 
      49           3 : BOOST_AUTO_TEST_CASE(test_main)
      50             : {
      51           2 :   Trace t;
      52             : 
      53           1 :   BOOST_REQUIRE(read_trace(t,trace_str));
      54             : 
      55           1 :   BOOST_REQUIRE(t.number_of_actions() == 3);
      56             : 
      57           1 :   test_next_action(t,"a");
      58           1 :   test_next_action(t,"b(1,true)");
      59           1 :   test_next_action(t,"c");
      60           4 : }

Generated by: LCOV version 1.13