GuardedExitTest.cc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include <string>
  3. #include "gtest/gtest.h"
  4. #include "GuardedExit.h"
  5. #include "sc_runner.h"
  6. #include "sc_types.h"
  7. static GuardedExit* statechart;
  8. //! The timers are managed by a timer service. */
  9. static SctUnitRunner * runner;
  10. class GuardedExitTest : public ::testing::Test{
  11. protected:
  12. virtual void SetUp() {
  13. statechart = new GuardedExit();
  14. statechart->init();
  15. runner = new SctUnitRunner(
  16. statechart,
  17. false,
  18. 200
  19. );
  20. }
  21. virtual void TearDown() {
  22. delete statechart;
  23. delete runner;
  24. }
  25. };
  26. void checkDone(bool shouldBeDone){
  27. statechart->getDefaultSCI()->raise_e();
  28. runner->proceed_cycles(1);
  29. EXPECT_TRUE(statechart->isStateActive(GuardedExit::main_region_B));
  30. EXPECT_TRUE(shouldBeDone ? statechart->getDefaultSCI()->get_done() : !statechart->getDefaultSCI()->get_done());
  31. }
  32. TEST_F(GuardedExitTest, ExitTaken) {
  33. statechart->enter();
  34. EXPECT_TRUE(statechart->isStateActive(GuardedExit::main_region_A));
  35. EXPECT_TRUE(!statechart->getDefaultSCI()->get_guard());
  36. checkDone(false);
  37. }
  38. TEST_F(GuardedExitTest, ExitNotTaken) {
  39. statechart->enter();
  40. EXPECT_TRUE(statechart->isStateActive(GuardedExit::main_region_A));
  41. statechart->getDefaultSCI()->set_guard(true);
  42. checkDone(true);
  43. }