DeepHistoryTest.cc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "DeepHistory.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 DeepHistory statechart;
  8. class DeepHistoryTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. deepHistory_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &deepHistory_runCycle,
  16. false,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. TEST_F(DeepHistoryTest, deepHistoryTest) {
  23. deepHistory_enter(&statechart);
  24. deepHistoryIface_raise_event1(&statechart);
  25. sc_timer_service_proceed_cycles(&timer_service, 1);
  26. deepHistoryIface_raise_event3(&statechart);
  27. sc_timer_service_proceed_cycles(&timer_service, 1);
  28. deepHistoryIface_raise_event5(&statechart);
  29. sc_timer_service_proceed_cycles(&timer_service, 1);
  30. deepHistoryIface_raise_event7(&statechart);
  31. sc_timer_service_proceed_cycles(&timer_service, 1);
  32. EXPECT_TRUE(!deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State1));
  33. EXPECT_TRUE(deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  34. deepHistoryIface_raise_event2(&statechart);
  35. sc_timer_service_proceed_cycles(&timer_service, 1);
  36. EXPECT_TRUE(deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State1));
  37. EXPECT_TRUE(!deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  38. deepHistoryIface_raise_event1(&statechart);
  39. sc_timer_service_proceed_cycles(&timer_service, 1);
  40. EXPECT_TRUE(!deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State1));
  41. EXPECT_TRUE(deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  42. }