ExitStateTest.cc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "ExitState.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 ExitState statechart;
  8. class ExitStateTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. exitState_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &exitState_runCycle,
  16. false,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. TEST_F(ExitStateTest, defaultExit) {
  23. exitState_enter(&statechart);
  24. EXPECT_TRUE(exitState_isStateActive(&statechart, ExitState_r_A));
  25. exitStateIface_raise_e(&statechart);
  26. sc_timer_service_proceed_cycles(&timer_service, 1);
  27. EXPECT_TRUE(exitState_isStateActive(&statechart, ExitState_r_E));
  28. }
  29. TEST_F(ExitStateTest, namedExitThroughNamedTransition) {
  30. exitState_enter(&statechart);
  31. EXPECT_TRUE(exitState_isStateActive(&statechart, ExitState_r_A));
  32. exitStateIface_raise_f(&statechart);
  33. sc_timer_service_proceed_cycles(&timer_service, 1);
  34. EXPECT_TRUE(exitState_isStateActive(&statechart, ExitState_r_F));
  35. }
  36. TEST_F(ExitStateTest, namedExitThroughDefaultTransition) {
  37. exitState_enter(&statechart);
  38. EXPECT_TRUE(exitState_isStateActive(&statechart, ExitState_r_A));
  39. exitStateIface_raise_g(&statechart);
  40. sc_timer_service_proceed_cycles(&timer_service, 1);
  41. EXPECT_TRUE(exitState_isStateActive(&statechart, ExitState_r_E));
  42. }
  43. TEST_F(ExitStateTest, remainInA) {
  44. exitState_enter(&statechart);
  45. EXPECT_TRUE(exitState_isStateActive(&statechart, ExitState_r_A));
  46. sc_timer_service_proceed_cycles(&timer_service, 1);
  47. EXPECT_TRUE(exitState_isStateActive(&statechart, ExitState_r_A));
  48. }