ShallowHistoryWithDeepEntryTest.cc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include <string>
  3. #include "gtest/gtest.h"
  4. #include "ShallowHistoryWithDeepEntry.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 ShallowHistoryWithDeepEntryTest : public ::testing::Test{
  11. protected:
  12. ShallowHistoryWithDeepEntry* statechart;
  13. virtual void SetUp() {
  14. statechart = new ShallowHistoryWithDeepEntry();
  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(ShallowHistoryWithDeepEntryTest, noDeepEntryWithinHistory) {
  28. statechart->enter();
  29. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  30. statechart->getDefaultSCI()->raise_toZ();
  31. runner->proceed_cycles(1);
  32. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  33. statechart->getDefaultSCI()->raise_toY();
  34. runner->proceed_cycles(1);
  35. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  36. statechart->getDefaultSCI()->raise_toZ();
  37. runner->proceed_cycles(1);
  38. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  39. }
  40. TEST_F(ShallowHistoryWithDeepEntryTest, deepEntryWithinHistory) {
  41. statechart->enter();
  42. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  43. statechart->getDefaultSCI()->raise_toZ();
  44. runner->proceed_cycles(1);
  45. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  46. statechart->getDefaultSCI()->raise_toC();
  47. runner->proceed_cycles(1);
  48. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  49. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  50. statechart->getDefaultSCI()->raise_toY();
  51. runner->proceed_cycles(1);
  52. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  53. statechart->getDefaultSCI()->raise_toZ();
  54. runner->proceed_cycles(1);
  55. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  56. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  57. }
  58. TEST_F(ShallowHistoryWithDeepEntryTest, directDeepEntryIntoHistory) {
  59. statechart->enter();
  60. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  61. statechart->getDefaultSCI()->raise_toC();
  62. runner->proceed_cycles(1);
  63. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  64. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  65. statechart->getDefaultSCI()->raise_toY();
  66. runner->proceed_cycles(1);
  67. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  68. statechart->getDefaultSCI()->raise_toZ();
  69. runner->proceed_cycles(1);
  70. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  71. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  72. }
  73. }