ShallowHistoryWithDeepEntryTest.cc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * Copyright (c) 2017 committers of YAKINDU and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * committers of YAKINDU - initial API and implementation
  10. */
  11. #include <string>
  12. #include "gtest/gtest.h"
  13. #include "ShallowHistoryWithDeepEntry.h"
  14. #include "sc_types.h"
  15. static ShallowHistoryWithDeepEntry* statechart;
  16. class StatemachineTest : public ::testing::Test{
  17. protected:
  18. virtual void SetUp() {
  19. statechart = new ShallowHistoryWithDeepEntry();
  20. statechart->init();
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. }
  25. };
  26. TEST_F(StatemachineTest, noDeepEntryWithinHistory) {
  27. statechart->enter();
  28. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  29. statechart->getDefaultSCI()->raise_toZ();
  30. statechart->runCycle();;
  31. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  32. statechart->getDefaultSCI()->raise_toY();
  33. statechart->runCycle();;
  34. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  35. statechart->getDefaultSCI()->raise_toZ();
  36. statechart->runCycle();;
  37. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  38. }
  39. TEST_F(StatemachineTest, deepEntryWithinHistory) {
  40. statechart->enter();
  41. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  42. statechart->getDefaultSCI()->raise_toZ();
  43. statechart->runCycle();;
  44. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  45. statechart->getDefaultSCI()->raise_toC();
  46. statechart->runCycle();;
  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. statechart->runCycle();;
  51. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  52. statechart->getDefaultSCI()->raise_toZ();
  53. statechart->runCycle();;
  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(StatemachineTest, directDeepEntryIntoHistory) {
  58. statechart->enter();
  59. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  60. statechart->getDefaultSCI()->raise_toC();
  61. statechart->runCycle();;
  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. statechart->runCycle();;
  66. EXPECT_TRUE(statechart->isStateActive(ShallowHistoryWithDeepEntry::main_region_Y));
  67. statechart->getDefaultSCI()->raise_toZ();
  68. statechart->runCycle();;
  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. }