OutEventLifeCycleTest.cc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. //! The timers are managed by a timer service. */
  8. static SctUnitRunner * runner;
  9. class OutEventLifeCycleTest : public ::testing::Test{
  10. protected:
  11. OutEventLifeCycle* statechart;
  12. virtual void SetUp() {
  13. statechart = new OutEventLifeCycle();
  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. virtual void init(bool sndCycle) {
  26. statechart->enter();
  27. statechart->getDefaultSCI()->raise_e();
  28. runner->proceed_cycles(1);
  29. if (sndCycle) {
  30. runner->proceed_cycles(1);
  31. }
  32. }
  33. };
  34. TEST_F(OutEventLifeCycleTest, availableAfterCycle) {
  35. statechart->enter();
  36. statechart->getDefaultSCI()->raise_e();
  37. runner->proceed_cycles(1);
  38. EXPECT_TRUE(statechart->getDefaultSCI()->isRaised_f());
  39. }
  40. TEST_F(OutEventLifeCycleTest, availableWithinCycle) {
  41. init(false);
  42. EXPECT_TRUE(statechart->getDefaultSCI()->get_f_available_in_cycle());
  43. }
  44. TEST_F(OutEventLifeCycleTest, unvailableWithin2ndCycle) {
  45. init(true);
  46. EXPECT_TRUE(!statechart->getDefaultSCI()->get_f_available_in_next_cycle());
  47. }
  48. TEST_F(OutEventLifeCycleTest, unvailableAfter2ndCycle) {
  49. init(true);
  50. EXPECT_TRUE(!statechart->getDefaultSCI()->isRaised_f());
  51. }