ShallowHistoryWithDeepEntryTest.cc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. static ShallowHistoryWithDeepEntry* statechart;
  8. //! The timers are managed by a timer service. */
  9. static SctUnitRunner * runner;
  10. class ShallowHistoryWithDeepEntryTest : public ::testing::Test{
  11. protected:
  12. virtual void SetUp() {
  13. statechart = new ShallowHistoryWithDeepEntry();
  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(ShallowHistoryWithDeepEntryTest, noDeepEntryWithinHistory) {
  27. statechart->enter();
  28. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  29. statechart->getDefaultSCI()->raise_toZ();
  30. runner->proceed_cycles(1);
  31. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  32. statechart->getDefaultSCI()->raise_toY();
  33. runner->proceed_cycles(1);
  34. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  35. statechart->getDefaultSCI()->raise_toZ();
  36. runner->proceed_cycles(1);
  37. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  38. }
  39. TEST_F(ShallowHistoryWithDeepEntryTest, deepEntryWithinHistory) {
  40. statechart->enter();
  41. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  42. statechart->getDefaultSCI()->raise_toZ();
  43. runner->proceed_cycles(1);
  44. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  45. statechart->getDefaultSCI()->raise_toC();
  46. runner->proceed_cycles(1);
  47. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  48. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  49. statechart->getDefaultSCI()->raise_toY();
  50. runner->proceed_cycles(1);
  51. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  52. statechart->getDefaultSCI()->raise_toZ();
  53. runner->proceed_cycles(1);
  54. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  55. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  56. }
  57. TEST_F(ShallowHistoryWithDeepEntryTest, directDeepEntryIntoHistory) {
  58. statechart->enter();
  59. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  60. statechart->getDefaultSCI()->raise_toC();
  61. runner->proceed_cycles(1);
  62. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  63. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  64. statechart->getDefaultSCI()->raise_toY();
  65. runner->proceed_cycles(1);
  66. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  67. statechart->getDefaultSCI()->raise_toZ();
  68. runner->proceed_cycles(1);
  69. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  70. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  71. }