ReadOnlyVariableTest.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include "gtest/gtest.h"
  3. #include "ReadOnlyVariable.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 ReadOnlyVariable statechart;
  8. class ReadOnlyVariableTest : public ::testing::Test{
  9. protected:
  10. virtual void SetUp() {
  11. readOnlyVariable_init(&statechart);
  12. sc_timer_service_init(
  13. &timer_service,
  14. 0,
  15. (sc_run_cycle_fp) &readOnlyVariable_runCycle,
  16. false,
  17. 200,
  18. &statechart
  19. );
  20. }
  21. };
  22. TEST_F(ReadOnlyVariableTest, ReadOnlyVariableTest) {
  23. readOnlyVariable_enter(&statechart);
  24. EXPECT_TRUE(readOnlyVariable_isStateActive(&statechart, ReadOnlyVariable_main_region_StateA));
  25. EXPECT_TRUE(readOnlyVariableIface_get_myInt(&statechart)== 0l);
  26. EXPECT_TRUE(strcmp(readOnlyVariableIface_get_myString(&statechart), "testString") == 0);
  27. EXPECT_TRUE(readOnlyVariableIface_get_myBool(&statechart)== true);
  28. EXPECT_TRUE(readOnlyVariableIface_get_myReal(&statechart)== 1.1);
  29. EXPECT_TRUE(readOnlyVariableIfaceA_get_myInt(&statechart) == 0l);
  30. EXPECT_TRUE(strcmp(readOnlyVariableIfaceA_get_myString(&statechart) , "testString") == 0);
  31. EXPECT_TRUE(readOnlyVariableIfaceA_get_myBool(&statechart) == true);
  32. EXPECT_TRUE(readOnlyVariableIfaceA_get_myReal(&statechart) == 1.1);
  33. sc_timer_service_proceed_cycles(&timer_service, 1);
  34. EXPECT_TRUE(readOnlyVariable_isStateActive(&statechart, ReadOnlyVariable_main_region_StateB));
  35. EXPECT_TRUE(readOnlyVariableIface_get_myInt(&statechart)== 100l);
  36. EXPECT_TRUE(strcmp(readOnlyVariableIface_get_myString(&statechart), "fail") == 0);
  37. EXPECT_TRUE(readOnlyVariableIface_get_myBool(&statechart)== false);
  38. EXPECT_TRUE(readOnlyVariableIface_get_myReal(&statechart)== 6.6);
  39. EXPECT_TRUE(readOnlyVariableIfaceA_get_myInt(&statechart) == 200l);
  40. EXPECT_TRUE(strcmp(readOnlyVariableIfaceA_get_myString(&statechart) , "A_fail") == 0);
  41. EXPECT_TRUE(readOnlyVariableIfaceA_get_myBool(&statechart) == false);
  42. EXPECT_TRUE(readOnlyVariableIfaceA_get_myReal(&statechart) == 7.7);
  43. }