NoLocalEventsTest.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "NoLocalEvents.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 NoLocalEvents statechart;
  8. class NoLocalEventsTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. noLocalEvents_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &noLocalEvents_runCycle,
  16. true,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. TEST_F(NoLocalEventsTest, test) {
  23. noLocalEvents_enter(&statechart);
  24. EXPECT_TRUE(noLocalEvents_isStateActive(&statechart, NoLocalEvents_main_region_StateA));
  25. noLocalEventsIface_raise_e(&statechart);
  26. EXPECT_TRUE(noLocalEvents_isStateActive(&statechart, NoLocalEvents_main_region_StateB));
  27. noLocalEventsIface_raise_e(&statechart);
  28. EXPECT_TRUE(noLocalEvents_isStateActive(&statechart, NoLocalEvents_main_region_StateA));
  29. EXPECT_TRUE((noLocalEventsIface_get_x(&statechart)== 0l));
  30. noLocalEventsIface_raise_i(&statechart, 42l);
  31. EXPECT_TRUE(noLocalEvents_isStateActive(&statechart, NoLocalEvents_main_region_StateB));
  32. EXPECT_TRUE((noLocalEventsIface_get_x(&statechart)== 42l));
  33. noLocalEvents_exit(&statechart);
  34. }