ParentFirstLocalReactionsTest.cc 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "ParentFirstLocalReactions.h"
  4. #include "sc_timer_service.h"
  5. static long counter = 0l;
  6. //! The timers are managed by a timer service. */
  7. static sc_unit_timer_service_t timer_service;
  8. static ParentFirstLocalReactions statechart;
  9. class ParentFirstLocalReactionsTest : public ::testing::Test{
  10. protected:
  11. virtual void SetUp() {
  12. parentFirstLocalReactions_init(&statechart);
  13. sc_timer_service_init(
  14. &timer_service,
  15. 0,
  16. (sc_run_cycle_fp) &parentFirstLocalReactions_runCycle,
  17. false,
  18. 200,
  19. &statechart
  20. );
  21. }
  22. };
  23. TEST_F(ParentFirstLocalReactionsTest, expectBottomUpLocalReactionOrder) {
  24. parentFirstLocalReactions_enter(&statechart);
  25. EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
  26. sc_timer_service_proceed_cycles(&timer_service, 1);
  27. EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
  28. EXPECT_TRUE(parentFirstLocalReactionsIface_get_sm_local(&statechart)== 1l);
  29. EXPECT_TRUE(parentFirstLocalReactionsIface_get_a_local(&statechart)== 2l);
  30. EXPECT_TRUE(parentFirstLocalReactionsIface_get_aa_local(&statechart)== 3l);
  31. EXPECT_TRUE(parentFirstLocalReactionsIface_get_aaa_local(&statechart)== 4l);
  32. }
  33. TEST_F(ParentFirstLocalReactionsTest, expectParentLocalReactionOnChildLocalTransition) {
  34. parentFirstLocalReactions_enter(&statechart);
  35. EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
  36. parentFirstLocalReactionsIface_raise_e(&statechart);
  37. parentFirstLocalReactionsIface_set_disable_a(&statechart,true);
  38. parentFirstLocalReactionsIface_set_disable_aa(&statechart,true);
  39. sc_timer_service_proceed_cycles(&timer_service, 1);
  40. EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAB));
  41. EXPECT_TRUE(parentFirstLocalReactionsIface_get_sm_local(&statechart)== 1l);
  42. EXPECT_TRUE(parentFirstLocalReactionsIface_get_a_local(&statechart)== 2l);
  43. EXPECT_TRUE(parentFirstLocalReactionsIface_get_aa_local(&statechart)== 3l);
  44. EXPECT_TRUE(parentFirstLocalReactionsIface_get_aaa_local(&statechart)== 0l);
  45. }
  46. TEST_F(ParentFirstLocalReactionsTest, expectGrandparentLocalReactionOnParentLocalTransition) {
  47. parentFirstLocalReactions_enter(&statechart);
  48. EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
  49. parentFirstLocalReactionsIface_set_disable_a(&statechart,true);
  50. parentFirstLocalReactionsIface_raise_e(&statechart);
  51. sc_timer_service_proceed_cycles(&timer_service, 1);
  52. EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AB));
  53. EXPECT_TRUE(parentFirstLocalReactionsIface_get_sm_local(&statechart)== 1l);
  54. EXPECT_TRUE(parentFirstLocalReactionsIface_get_a_local(&statechart)== 2l);
  55. EXPECT_TRUE(parentFirstLocalReactionsIface_get_aa_local(&statechart)== 0l);
  56. EXPECT_TRUE(parentFirstLocalReactionsIface_get_aaa_local(&statechart)== 0l);
  57. }
  58. TEST_F(ParentFirstLocalReactionsTest, expectNoLocalReactionOnGrandparentTransition) {
  59. parentFirstLocalReactions_enter(&statechart);
  60. EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
  61. parentFirstLocalReactionsIface_set_disable_aaa(&statechart,true);
  62. parentFirstLocalReactionsIface_set_disable_aa(&statechart,true);
  63. parentFirstLocalReactionsIface_raise_e(&statechart);
  64. sc_timer_service_proceed_cycles(&timer_service, 1);
  65. EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_B));
  66. EXPECT_TRUE(parentFirstLocalReactionsIface_get_sm_local(&statechart)== 1l);
  67. EXPECT_TRUE(parentFirstLocalReactionsIface_get_a_local(&statechart)== 0l);
  68. EXPECT_TRUE(parentFirstLocalReactionsIface_get_aa_local(&statechart)== 0l);
  69. EXPECT_TRUE(parentFirstLocalReactionsIface_get_aaa_local(&statechart)== 0l);
  70. }