12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- /* Generated by YAKINDU Statechart Tools code generator. */
- #include "gtest/gtest.h"
- #include "ParentFirstLocalReactions.h"
- #include "sc_timer_service.h"
- static long counter = 0l;
- //! The timers are managed by a timer service. */
- static sc_unit_timer_service_t timer_service;
- static ParentFirstLocalReactions statechart;
- class ParentFirstLocalReactionsTest : public ::testing::Test{
- protected:
- virtual void SetUp() {
- parentFirstLocalReactions_init(&statechart);
- sc_timer_service_init(
- &timer_service,
- 0,
- (sc_run_cycle_fp) &parentFirstLocalReactions_runCycle,
- false,
- 200,
- &statechart
- );
- }
- };
- TEST_F(ParentFirstLocalReactionsTest, expectBottomUpLocalReactionOrder) {
- parentFirstLocalReactions_enter(&statechart);
- EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
- sc_timer_service_proceed_cycles(&timer_service, 1);
- EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_sm_local(&statechart)== 1l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_a_local(&statechart)== 2l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_aa_local(&statechart)== 3l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_aaa_local(&statechart)== 4l);
- }
- TEST_F(ParentFirstLocalReactionsTest, expectParentLocalReactionOnChildLocalTransition) {
- parentFirstLocalReactions_enter(&statechart);
- EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
- parentFirstLocalReactionsIface_raise_e(&statechart);
- parentFirstLocalReactionsIface_set_disable_a(&statechart,true);
- parentFirstLocalReactionsIface_set_disable_aa(&statechart,true);
- sc_timer_service_proceed_cycles(&timer_service, 1);
- EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAB));
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_sm_local(&statechart)== 1l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_a_local(&statechart)== 2l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_aa_local(&statechart)== 3l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_aaa_local(&statechart)== 0l);
- }
- TEST_F(ParentFirstLocalReactionsTest, expectGrandparentLocalReactionOnParentLocalTransition) {
- parentFirstLocalReactions_enter(&statechart);
- EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
- parentFirstLocalReactionsIface_set_disable_a(&statechart,true);
- parentFirstLocalReactionsIface_raise_e(&statechart);
- sc_timer_service_proceed_cycles(&timer_service, 1);
- EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AB));
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_sm_local(&statechart)== 1l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_a_local(&statechart)== 2l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_aa_local(&statechart)== 0l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_aaa_local(&statechart)== 0l);
- }
- TEST_F(ParentFirstLocalReactionsTest, expectNoLocalReactionOnGrandparentTransition) {
- parentFirstLocalReactions_enter(&statechart);
- EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_A_r_AA_r_AAA));
- parentFirstLocalReactionsIface_set_disable_aaa(&statechart,true);
- parentFirstLocalReactionsIface_set_disable_aa(&statechart,true);
- parentFirstLocalReactionsIface_raise_e(&statechart);
- sc_timer_service_proceed_cycles(&timer_service, 1);
- EXPECT_TRUE(parentFirstLocalReactions_isStateActive(&statechart, ParentFirstLocalReactions_ParentFirstLocalReactions_r_B));
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_sm_local(&statechart)== 1l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_a_local(&statechart)== 0l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_aa_local(&statechart)== 0l);
- EXPECT_TRUE(parentFirstLocalReactionsIface_get_aaa_local(&statechart)== 0l);
- }
|