AssignmentAsExpressionTest.cc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "AssignmentAsExpression.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 AssignmentAsExpression statechart;
  8. class AssignmentAsExpressionTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. assignmentAsExpression_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &assignmentAsExpression_runCycle,
  16. false,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. TEST_F(AssignmentAsExpressionTest, simpleAssignment) {
  23. assignmentAsExpression_enter(&statechart);
  24. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_Add));
  25. EXPECT_TRUE(assignmentAsExpressionIface_get_b(&statechart)== 5l);
  26. EXPECT_TRUE(assignmentAsExpressionIface_get_a(&statechart)== 9l);
  27. sc_timer_service_proceed_cycles(&timer_service, 1);
  28. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_Subtract));
  29. EXPECT_TRUE(assignmentAsExpressionIface_get_d(&statechart)== 6l);
  30. sc_timer_service_proceed_cycles(&timer_service, 1);
  31. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_Multiply));
  32. EXPECT_TRUE(assignmentAsExpressionIface_get_e(&statechart)== 15l);
  33. sc_timer_service_proceed_cycles(&timer_service, 1);
  34. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_Divide));
  35. EXPECT_TRUE(assignmentAsExpressionIface_get_g(&statechart)== 1l);
  36. sc_timer_service_proceed_cycles(&timer_service, 1);
  37. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_Modulo));
  38. EXPECT_TRUE(assignmentAsExpressionIface_get_i(&statechart)== 1l);
  39. sc_timer_service_proceed_cycles(&timer_service, 1);
  40. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_Shift));
  41. EXPECT_TRUE(assignmentAsExpressionIface_get_j(&statechart)== 16l);
  42. EXPECT_TRUE(assignmentAsExpressionIface_get_k(&statechart)== 4l);
  43. sc_timer_service_proceed_cycles(&timer_service, 1);
  44. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_boolean_And));
  45. EXPECT_TRUE(assignmentAsExpressionIface_get_l(&statechart)== 1l);
  46. sc_timer_service_proceed_cycles(&timer_service, 1);
  47. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_boolean_Or));
  48. EXPECT_TRUE(assignmentAsExpressionIface_get_p(&statechart)== 15l);
  49. sc_timer_service_proceed_cycles(&timer_service, 1);
  50. EXPECT_TRUE(assignmentAsExpression_isStateActive(&statechart, AssignmentAsExpression_main_region_boolean_Xor));
  51. EXPECT_TRUE(assignmentAsExpressionIface_get_u(&statechart)== 12l);
  52. assignmentAsExpression_exit(&statechart);
  53. }