ReadOnlyVariableTest.cc 2.0 KB

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