123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- /* Generated by YAKINDU Statechart Tools code generator. */
- #include "gtest/gtest.h"
- #include "GuardedExit.h"
- #include "sc_timer_service.h"
- //! The timers are managed by a timer service. */
- static sc_unit_timer_service_t timer_service;
- static GuardedExit statechart;
- class GuardedExitTest : public ::testing::Test{
- protected:
- virtual void SetUp() {
- guardedExit_init(&statechart);
- sc_timer_service_init(
- &timer_service,
- 0,
- (sc_run_cycle_fp) &guardedExit_runCycle,
- false,
- 200,
- &statechart
- );
- }
- };
- void checkDone(bool shouldBeDone){
- guardedExitIface_raise_e(&statechart);
- sc_timer_service_proceed_cycles(&timer_service, 1);
- EXPECT_TRUE(guardedExit_isStateActive(&statechart, GuardedExit_main_region_B));
- EXPECT_TRUE(shouldBeDone ? guardedExitIface_get_done(&statechart) : !guardedExitIface_get_done(&statechart));
- }
- TEST_F(GuardedExitTest, ExitTaken) {
- guardedExit_enter(&statechart);
- EXPECT_TRUE(guardedExit_isStateActive(&statechart, GuardedExit_main_region_A));
- EXPECT_TRUE(!guardedExitIface_get_guard(&statechart));
- checkDone(false);
- }
- TEST_F(GuardedExitTest, ExitNotTaken) {
- guardedExit_enter(&statechart);
- EXPECT_TRUE(guardedExit_isStateActive(&statechart, GuardedExit_main_region_A));
- guardedExitIface_set_guard(&statechart,true);
- checkDone(true);
- }
|