OutEventLifeCycleTest.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include <string>
  3. #include "gtest/gtest.h"
  4. #include "OutEventLifeCycle.h"
  5. #include "sc_runner.h"
  6. #include "sc_types.h"
  7. namespace {
  8. //! The timers are managed by a timer service. */
  9. static SctUnitRunner * runner;
  10. class OutEventLifeCycleTest : public ::testing::Test{
  11. protected:
  12. OutEventLifeCycle* statechart;
  13. virtual void SetUp() {
  14. statechart = new OutEventLifeCycle();
  15. statechart->init();
  16. runner = new SctUnitRunner(
  17. statechart,
  18. false,
  19. 200
  20. );
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. delete runner;
  25. }
  26. virtual void init(bool sndCycle) {
  27. statechart->enter();
  28. statechart->getDefaultSCI()->raise_e();
  29. runner->proceed_cycles(1);
  30. if (sndCycle) {
  31. runner->proceed_cycles(1);
  32. }
  33. }
  34. };
  35. TEST_F(OutEventLifeCycleTest, availableAfterCycle) {
  36. statechart->enter();
  37. statechart->getDefaultSCI()->raise_e();
  38. runner->proceed_cycles(1);
  39. EXPECT_TRUE(statechart->getDefaultSCI()->isRaised_f());
  40. }
  41. TEST_F(OutEventLifeCycleTest, availableWithinCycle) {
  42. init(false);
  43. EXPECT_TRUE(statechart->getDefaultSCI()->get_f_available_in_cycle());
  44. }
  45. TEST_F(OutEventLifeCycleTest, unvailableWithin2ndCycle) {
  46. init(true);
  47. EXPECT_TRUE(!statechart->getDefaultSCI()->get_f_available_in_next_cycle());
  48. }
  49. TEST_F(OutEventLifeCycleTest, unvailableAfter2ndCycle) {
  50. init(true);
  51. EXPECT_TRUE(!statechart->getDefaultSCI()->isRaised_f());
  52. }
  53. }