ValuedEventsTest.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "ValuedEvents.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 ValuedEvents statechart;
  8. class ValuedEventsTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. valuedEvents_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &valuedEvents_runCycle,
  16. false,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. TEST_F(ValuedEventsTest, valuedEventsTest) {
  23. valuedEvents_enter(&statechart);
  24. sc_timer_service_proceed_cycles(&timer_service, 1);
  25. EXPECT_TRUE(strcmp(valuedEventsIface_get_myString(&statechart), "sct") == 0);
  26. valuedEventsIface_raise_integerEvent(&statechart, 23l);
  27. valuedEventsIface_raise_booleanEvent(&statechart, false);
  28. valuedEventsIface_raise_realEvent(&statechart, 20l);
  29. valuedEventsIface_raise_stringEvent(&statechart, "tool");
  30. sc_timer_service_proceed_cycles(&timer_service, 1);
  31. EXPECT_TRUE(valuedEvents_isStateActive(&statechart, ValuedEvents_integer_region_D));
  32. EXPECT_TRUE(valuedEvents_isStateActive(&statechart, ValuedEvents_string_region_D));
  33. EXPECT_TRUE(valuedEvents_isStateActive(&statechart, ValuedEvents_boolean_region_D));
  34. EXPECT_TRUE(valuedEvents_isStateActive(&statechart, ValuedEvents_real_region_D));
  35. EXPECT_TRUE(valuedEventsIface_get_myInt(&statechart)== 23l);
  36. EXPECT_TRUE(valuedEventsIface_get_myBool(&statechart)== false);
  37. EXPECT_TRUE(valuedEventsIface_get_myReal(&statechart)== 20l);
  38. EXPECT_TRUE(strcmp(valuedEventsIface_get_myString(&statechart), "tool") == 0);
  39. }