ChildFirstLocalReactionsTest.cc 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "ChildFirstLocalReactions.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 ChildFirstLocalReactions statechart;
  9. class ChildFirstLocalReactionsTest : public ::testing::Test{
  10. protected:
  11. virtual void SetUp() {
  12. childFirstLocalReactions_init(&statechart);
  13. sc_timer_service_init(
  14. &timer_service,
  15. 0,
  16. (sc_run_cycle_fp) &childFirstLocalReactions_runCycle,
  17. false,
  18. 200,
  19. &statechart
  20. );
  21. }
  22. };
  23. TEST_F(ChildFirstLocalReactionsTest, expectBottomUpLocalReactionOrder) {
  24. childFirstLocalReactions_enter(&statechart);
  25. EXPECT_TRUE(childFirstLocalReactions_isStateActive(&statechart, ChildFirstLocalReactions_ChildFirstLocalReactions_r_A_r_AA_r_AAA));
  26. sc_timer_service_proceed_cycles(&timer_service, 1);
  27. EXPECT_TRUE(childFirstLocalReactions_isStateActive(&statechart, ChildFirstLocalReactions_ChildFirstLocalReactions_r_A_r_AA_r_AAA));
  28. EXPECT_TRUE(childFirstLocalReactionsIface_get_aaa_local(&statechart)== 1l);
  29. EXPECT_TRUE(childFirstLocalReactionsIface_get_aa_local(&statechart)== 2l);
  30. EXPECT_TRUE(childFirstLocalReactionsIface_get_a_local(&statechart)== 3l);
  31. EXPECT_TRUE(childFirstLocalReactionsIface_get_sm_local(&statechart)== 4l);
  32. }
  33. TEST_F(ChildFirstLocalReactionsTest, expectParentLocalReactionOnChildLocalTransition) {
  34. childFirstLocalReactions_enter(&statechart);
  35. EXPECT_TRUE(childFirstLocalReactions_isStateActive(&statechart, ChildFirstLocalReactions_ChildFirstLocalReactions_r_A_r_AA_r_AAA));
  36. childFirstLocalReactionsIface_raise_e(&statechart);
  37. sc_timer_service_proceed_cycles(&timer_service, 1);
  38. EXPECT_TRUE(childFirstLocalReactions_isStateActive(&statechart, ChildFirstLocalReactions_ChildFirstLocalReactions_r_A_r_AA_r_AAB));
  39. EXPECT_TRUE(childFirstLocalReactionsIface_get_aaa_local(&statechart)== 0l);
  40. EXPECT_TRUE(childFirstLocalReactionsIface_get_aa_local(&statechart)== 1l);
  41. EXPECT_TRUE(childFirstLocalReactionsIface_get_a_local(&statechart)== 2l);
  42. EXPECT_TRUE(childFirstLocalReactionsIface_get_sm_local(&statechart)== 3l);
  43. }
  44. TEST_F(ChildFirstLocalReactionsTest, expectGrandparentLocalReactionOnParentLocalTransition) {
  45. childFirstLocalReactions_enter(&statechart);
  46. EXPECT_TRUE(childFirstLocalReactions_isStateActive(&statechart, ChildFirstLocalReactions_ChildFirstLocalReactions_r_A_r_AA_r_AAA));
  47. childFirstLocalReactionsIface_set_disable_aaa(&statechart,true);
  48. childFirstLocalReactionsIface_raise_e(&statechart);
  49. sc_timer_service_proceed_cycles(&timer_service, 1);
  50. EXPECT_TRUE(childFirstLocalReactions_isStateActive(&statechart, ChildFirstLocalReactions_ChildFirstLocalReactions_r_A_r_AB));
  51. EXPECT_TRUE(childFirstLocalReactionsIface_get_aaa_local(&statechart)== 1l);
  52. EXPECT_TRUE(childFirstLocalReactionsIface_get_aa_local(&statechart)== 0l);
  53. EXPECT_TRUE(childFirstLocalReactionsIface_get_a_local(&statechart)== 2l);
  54. EXPECT_TRUE(childFirstLocalReactionsIface_get_sm_local(&statechart)== 3l);
  55. }
  56. TEST_F(ChildFirstLocalReactionsTest, expectNoLocalReactionOnGrandparentTransition) {
  57. childFirstLocalReactions_enter(&statechart);
  58. EXPECT_TRUE(childFirstLocalReactions_isStateActive(&statechart, ChildFirstLocalReactions_ChildFirstLocalReactions_r_A_r_AA_r_AAA));
  59. childFirstLocalReactionsIface_set_disable_aaa(&statechart,true);
  60. childFirstLocalReactionsIface_set_disable_aa(&statechart,true);
  61. childFirstLocalReactionsIface_raise_e(&statechart);
  62. sc_timer_service_proceed_cycles(&timer_service, 1);
  63. EXPECT_TRUE(childFirstLocalReactions_isStateActive(&statechart, ChildFirstLocalReactions_ChildFirstLocalReactions_r_B));
  64. EXPECT_TRUE(childFirstLocalReactionsIface_get_aaa_local(&statechart)== 1l);
  65. EXPECT_TRUE(childFirstLocalReactionsIface_get_aa_local(&statechart)== 2l);
  66. EXPECT_TRUE(childFirstLocalReactionsIface_get_a_local(&statechart)== 0l);
  67. EXPECT_TRUE(childFirstLocalReactionsIface_get_sm_local(&statechart)== 3l);
  68. }