InternalEventLifeCycleTest.cc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "InternalEventLifeCycle.h"
  4. #include "sc_timer_service.h"
  5. //! The timers are managed by a timer service. */
  6. static sc_unit_timer_service_t timer_service;
  7. static IntlEvent statechart;
  8. class InternalEventLifeCycleTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. intlEvent_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &intlEvent_runCycle,
  16. false,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. TEST_F(InternalEventLifeCycleTest, InternalEventLifeCycleTest) {
  23. intlEvent_enter(&statechart);
  24. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r1_A));
  25. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r2_C));
  26. intlEvent_raise_e(&statechart);
  27. sc_timer_service_proceed_cycles(&timer_service, 1);
  28. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r1_A));
  29. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r2_D));
  30. sc_timer_service_proceed_cycles(&timer_service, 1);
  31. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r1_A));
  32. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r2_D));
  33. intlEvent_raise_f(&statechart);
  34. sc_timer_service_proceed_cycles(&timer_service, 1);
  35. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r1_A));
  36. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r2_C));
  37. sc_timer_service_proceed_cycles(&timer_service, 1);
  38. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r1_A));
  39. EXPECT_TRUE(intlEvent_isStateActive(&statechart, intlEvent_r2_C));
  40. }