StatechartLocalReactionsTest.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "StatechartLocalReactions.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 StatechartLocalReactions statechart;
  8. class StatechartLocalReactionsTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. statechartLocalReactions_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &statechartLocalReactions_runCycle,
  16. false,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. TEST_F(StatechartLocalReactionsTest, statechartLocalReactionsTest) {
  23. statechartLocalReactions_enter(&statechart);
  24. EXPECT_TRUE(statechartLocalReactions_isStateActive(&statechart, StatechartLocalReactions_main_region_S1));
  25. EXPECT_TRUE(statechartLocalReactions_isStateActive(&statechart, StatechartLocalReactions_region2_a));
  26. while (statechartLocalReactionsIface_get_myInt(&statechart)< 10l) {
  27. EXPECT_TRUE(statechartLocalReactions_isStateActive(&statechart, StatechartLocalReactions_region2_a));
  28. if (statechartLocalReactionsIface_get_myInt(&statechart)%2l== 0l) {
  29. EXPECT_TRUE(statechartLocalReactions_isStateActive(&statechart, StatechartLocalReactions_main_region_S1));
  30. }
  31. else {
  32. EXPECT_TRUE(statechartLocalReactions_isStateActive(&statechart, StatechartLocalReactions_main_region_S2));
  33. }
  34. sc_timer_service_proceed_cycles(&timer_service, 1);
  35. }
  36. }