LearnTA  0.0.1
manual_eq_tester.hh
1 
6 #pragma once
7 
8 #include "timed_automaton_runner.hh"
9 
10 namespace learnta {
11  struct ManualEqTester {
12  TimedAutomatonRunner expected, hypothesis;
13 
15  expected(std::move(expected)), hypothesis(std::move(hypothesis)) {
16  }
17 
18  void run(std::string word, std::vector<double> durations, int wrongLast = 0) {
19  hypothesis.pre();
20  expected.pre();
21  for (std::size_t i = 0; i < word.size(); ++i) {
22  if (i + wrongLast <= word.size()) {
23  BOOST_CHECK_EQUAL(expected.step(durations.at(i)), hypothesis.step(durations.at(i)));
24  } else {
25  BOOST_CHECK_NE(expected.step(durations.at(i)), hypothesis.step(durations.at(i)));
26  }
27  if (i + wrongLast < word.size()) {
28  BOOST_CHECK_EQUAL(expected.step(word.at(i)), hypothesis.step(word.at(i)));
29  } else {
30  BOOST_CHECK_NE(expected.step(word.at(i)), hypothesis.step(word.at(i)));
31  }
32  }
33  if (durations.size() > word.size()) {
34  if (wrongLast <= 0) {
35  BOOST_CHECK_EQUAL(expected.step(durations.back()), hypothesis.step(durations.back()));
36  } else {
37  BOOST_CHECK_NE(expected.step(durations.back()), hypothesis.step(durations.back()));
38  }
39  }
40  hypothesis.post();
41  expected.post();
42  }
43 
44  };
45 }
Class to execute a timed automaton.
Definition: timed_automaton_runner.hh:22
bool step(char action) override
Feed a discrete action.
Definition: timed_automaton_runner.hh:80
void post() override
The function should be called after feeding each timed word.
Definition: timed_automaton_runner.hh:51
void pre() override
Reset the configuration.
Definition: timed_automaton_runner.hh:41
Definition: experiment_runner.hh:23
Definition: manual_eq_tester.hh:11