OutEventLifeCycleTest.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "OutEventLifeCycle.h"
  4. #include "sc_timer_service.h"
  5. //! The timers are managed by a timer service. */
  6. static sc_unit_timer_service_t timer_service;
  7. static OutEventLifeCycle statechart;
  8. class OutEventLifeCycleTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. outEventLifeCycle_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &outEventLifeCycle_runCycle,
  16. false,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. void init(bool sndCycle){
  23. outEventLifeCycle_enter(&statechart);
  24. outEventLifeCycleIface_raise_e(&statechart);
  25. sc_timer_service_proceed_cycles(&timer_service, 1);
  26. if (sndCycle) {
  27. sc_timer_service_proceed_cycles(&timer_service, 1);
  28. }
  29. }
  30. TEST_F(OutEventLifeCycleTest, availableAfterCycle) {
  31. outEventLifeCycle_enter(&statechart);
  32. outEventLifeCycleIface_raise_e(&statechart);
  33. sc_timer_service_proceed_cycles(&timer_service, 1);
  34. EXPECT_TRUE(outEventLifeCycleIface_israised_f(&statechart));
  35. }
  36. TEST_F(OutEventLifeCycleTest, availableWithinCycle) {
  37. init(false);
  38. EXPECT_TRUE(outEventLifeCycleIface_get_f_available_in_cycle(&statechart));
  39. }
  40. TEST_F(OutEventLifeCycleTest, unvailableWithin2ndCycle) {
  41. init(true);
  42. EXPECT_TRUE(!outEventLifeCycleIface_get_f_available_in_next_cycle(&statechart));
  43. }
  44. TEST_F(OutEventLifeCycleTest, unvailableAfter2ndCycle) {
  45. init(true);
  46. EXPECT_TRUE(!outEventLifeCycleIface_israised_f(&statechart));
  47. }