OutEventLifeCycleTest.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. static OutEventLifeCycle* statechart;
  8. //! The timers are managed by a timer service. */
  9. static SctUnitRunner * runner;
  10. class OutEventLifeCycleTest : public ::testing::Test{
  11. protected:
  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. };
  26. 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. 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. }