File: read_plain.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 (51 lines) | stat: -rwxr-xr-x 886 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
#include <boost/test/minimal.hpp>
#include <sstream>
#include "mcrl2/trace/trace.h"

using namespace std;
using namespace mcrl2::trace;

static const char* trace_str = "a\nb(1,true)\nc\n";

static bool read_trace(Trace& t, const char* s)
{
  stringstream ss(s);

  try
  {
    t.load(ss);
  }
  catch (...)
  {
    return false;
  }

  return true;
}

void test_next_action(Trace& t, const char* s)
{
  mcrl2::lps::multi_action a = t.currentAction();
  t.increasePosition();
  BOOST_CHECK(a != mcrl2::lps::multi_action());
  if (a != mcrl2::lps::multi_action())
  {
    BOOST_CHECK(a.actions().size() == 1);
    BOOST_CHECK(pp(a)==s);
  }
}

int test_main(int argc, char** argv)
{
  Trace t;

  BOOST_REQUIRE(read_trace(t,trace_str));

  BOOST_REQUIRE(t.number_of_actions() == 3);

  test_next_action(t,"a");
  test_next_action(t,"b(1,true)");
  test_next_action(t,"c");

  return 0;
}