ReadOnlyVariableTest.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include <string>
  3. #include "gtest/gtest.h"
  4. #include "ReadOnlyVariable.h"
  5. #include "sc_runner.h"
  6. #include "sc_types.h"
  7. static ReadOnlyVariable* statechart;
  8. //! The timers are managed by a timer service. */
  9. static SctUnitRunner * runner;
  10. class ReadOnlyVariableTest : public ::testing::Test{
  11. protected:
  12. virtual void SetUp() {
  13. statechart = new ReadOnlyVariable();
  14. statechart->init();
  15. runner = new SctUnitRunner(
  16. statechart,
  17. false,
  18. 200
  19. );
  20. }
  21. virtual void TearDown() {
  22. delete statechart;
  23. delete runner;
  24. }
  25. };
  26. TEST_F(ReadOnlyVariableTest, ReadOnlyVariableTest) {
  27. statechart->enter();
  28. EXPECT_TRUE(statechart->isStateActive(ReadOnlyVariable::main_region_StateA));
  29. EXPECT_TRUE(statechart->getDefaultSCI()->get_myInt()== 0l);
  30. EXPECT_TRUE(strcmp(statechart->getDefaultSCI()->get_myString(), "testString") == 0);
  31. EXPECT_TRUE(statechart->getDefaultSCI()->get_myBool()== true);
  32. EXPECT_TRUE(statechart->getDefaultSCI()->get_myReal()== 1.1);
  33. EXPECT_TRUE(statechart->getSCI_A()->get_myInt()== 0l);
  34. EXPECT_TRUE(strcmp(statechart->getSCI_A()->get_myString(), "testString") == 0);
  35. EXPECT_TRUE(statechart->getSCI_A()->get_myBool()== true);
  36. EXPECT_TRUE(statechart->getSCI_A()->get_myReal()== 1.1);
  37. runner->proceed_cycles(1);
  38. EXPECT_TRUE(statechart->isStateActive(ReadOnlyVariable::main_region_StateB));
  39. EXPECT_TRUE(statechart->getDefaultSCI()->get_myInt()== 100l);
  40. EXPECT_TRUE(strcmp(statechart->getDefaultSCI()->get_myString(), "fail") == 0);
  41. EXPECT_TRUE(statechart->getDefaultSCI()->get_myBool()== false);
  42. EXPECT_TRUE(statechart->getDefaultSCI()->get_myReal()== 6.6);
  43. EXPECT_TRUE(statechart->getSCI_A()->get_myInt()== 200l);
  44. EXPECT_TRUE(strcmp(statechart->getSCI_A()->get_myString(), "A_fail") == 0);
  45. EXPECT_TRUE(statechart->getSCI_A()->get_myBool()== false);
  46. EXPECT_TRUE(statechart->getSCI_A()->get_myReal()== 7.7);
  47. }