1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- /* Generated by YAKINDU Statechart Tools code generator. */
- #include "gtest/gtest.h"
- #include "Choice.h"
- #include "sc_timer_service.h"
- //! The timers are managed by a timer service. */
- static sc_unit_timer_service_t timer_service;
- static Choice statechart;
- class ChoiceTest : public ::testing::Test{
- protected:
- virtual void SetUp() {
- choice_init(&statechart);
- sc_timer_service_init(
- &timer_service,
- 0,
- (sc_run_cycle_fp) &choice_runCycle,
- false,
- 200,
- &statechart
- );
- }
- };
- void initForEventE(bool valueForC){
- choice_enter(&statechart);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_A));
- choiceIface_set_c(&statechart,valueForC);
- choiceIface_raise_e(&statechart);
- sc_timer_service_proceed_cycles(&timer_service, 1);
- }
- void initForEventF(bool valueForC){
- choice_enter(&statechart);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_A));
- choiceIface_set_c(&statechart,valueForC);
- choiceIface_raise_f(&statechart);
- sc_timer_service_proceed_cycles(&timer_service, 1);
- }
- void initForEventG(bool valueForC){
- choice_enter(&statechart);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_A));
- choiceIface_set_c(&statechart,valueForC);
- choiceIface_raise_g(&statechart);
- sc_timer_service_proceed_cycles(&timer_service, 1);
- }
- void initForEventH(bool valueForC){
- choice_enter(&statechart);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_A));
- choiceIface_set_c(&statechart,valueForC);
- choiceIface_raise_h(&statechart);
- sc_timer_service_proceed_cycles(&timer_service, 1);
- }
- TEST_F(ChoiceTest, elseChoiceUsingNonDefaultTransition) {
- initForEventE(true);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_C));
- }
- TEST_F(ChoiceTest, elseChoiceUsingDefaultTransition) {
- initForEventE(false);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_B));
- }
- TEST_F(ChoiceTest, defaultChoiceUsingNonDefaultTransition) {
- initForEventG(true);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_C));
- }
- TEST_F(ChoiceTest, defaultChoiceUsingDefaultTransition) {
- initForEventG(false);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_B));
- }
- TEST_F(ChoiceTest, uncheckedChoiceUsingNonDefaultTransition) {
- initForEventF(true);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_C));
- }
- TEST_F(ChoiceTest, uncheckedChoiceUsingDefaultTransition) {
- initForEventF(false);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_B));
- }
- TEST_F(ChoiceTest, alwaysTrueTransitionInChoice) {
- initForEventH(true);
- EXPECT_TRUE(choice_isStateActive(&statechart, Choice_main_region_C));
- }
|