ShallowHistoryWithDeepEntryTest.cc 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "gtest/gtest.h"
  12. #include "ShallowHistoryWithDeepEntry.h"
  13. ShallowHistoryWithDeepEntry handle;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. shallowHistoryWithDeepEntry_init(&handle);
  18. }
  19. };
  20. TEST_F(StatemachineTest, noDeepEntryWithinHistory) {
  21. shallowHistoryWithDeepEntry_enter(&handle);
  22. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  23. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  24. shallowHistoryWithDeepEntry_runCycle(&handle);
  25. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_A));
  26. shallowHistoryWithDeepEntryIface_raise_toY(&handle);
  27. shallowHistoryWithDeepEntry_runCycle(&handle);
  28. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  29. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  30. shallowHistoryWithDeepEntry_runCycle(&handle);
  31. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_A));
  32. }
  33. TEST_F(StatemachineTest, deepEntryWithinHistory) {
  34. shallowHistoryWithDeepEntry_enter(&handle);
  35. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  36. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  37. shallowHistoryWithDeepEntry_runCycle(&handle);
  38. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_A));
  39. shallowHistoryWithDeepEntryIface_raise_toC(&handle);
  40. shallowHistoryWithDeepEntry_runCycle(&handle);
  41. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B__region0_C));
  42. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B));
  43. shallowHistoryWithDeepEntryIface_raise_toY(&handle);
  44. shallowHistoryWithDeepEntry_runCycle(&handle);
  45. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  46. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  47. shallowHistoryWithDeepEntry_runCycle(&handle);
  48. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B__region0_C));
  49. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B));
  50. }
  51. TEST_F(StatemachineTest, directDeepEntryIntoHistory) {
  52. shallowHistoryWithDeepEntry_enter(&handle);
  53. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  54. shallowHistoryWithDeepEntryIface_raise_toC(&handle);
  55. shallowHistoryWithDeepEntry_runCycle(&handle);
  56. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B__region0_C));
  57. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B));
  58. shallowHistoryWithDeepEntryIface_raise_toY(&handle);
  59. shallowHistoryWithDeepEntry_runCycle(&handle);
  60. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  61. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  62. shallowHistoryWithDeepEntry_runCycle(&handle);
  63. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B__region0_C));
  64. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B));
  65. }