ShallowHistoryWithDeepEntry.cc 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * Copyright (c) 2016 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. ShallowHistoryWithDeepEntry handle;
  15. TEST(StatemachineTest, noDeepEntryWithinHistory) {
  16. shallowHistoryWithDeepEntry_init(&handle);
  17. shallowHistoryWithDeepEntry_enter(&handle);
  18. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  19. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  20. shallowHistoryWithDeepEntry_runCycle(&handle);
  21. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_A));
  22. shallowHistoryWithDeepEntryIface_raise_toY(&handle);
  23. shallowHistoryWithDeepEntry_runCycle(&handle);
  24. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  25. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  26. shallowHistoryWithDeepEntry_runCycle(&handle);
  27. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_A));
  28. }
  29. TEST(StatemachineTest, deepEntryWithinHistory) {
  30. shallowHistoryWithDeepEntry_init(&handle);
  31. shallowHistoryWithDeepEntry_enter(&handle);
  32. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  33. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  34. shallowHistoryWithDeepEntry_runCycle(&handle);
  35. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_A));
  36. shallowHistoryWithDeepEntryIface_raise_toC(&handle);
  37. shallowHistoryWithDeepEntry_runCycle(&handle);
  38. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B__region0_C));
  39. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B));
  40. shallowHistoryWithDeepEntryIface_raise_toY(&handle);
  41. shallowHistoryWithDeepEntry_runCycle(&handle);
  42. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  43. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  44. shallowHistoryWithDeepEntry_runCycle(&handle);
  45. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B__region0_C));
  46. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B));
  47. }
  48. TEST(StatemachineTest, directDeepEntryIntoHistory) {
  49. shallowHistoryWithDeepEntry_init(&handle);
  50. shallowHistoryWithDeepEntry_enter(&handle);
  51. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  52. shallowHistoryWithDeepEntryIface_raise_toC(&handle);
  53. shallowHistoryWithDeepEntry_runCycle(&handle);
  54. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B__region0_C));
  55. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B));
  56. shallowHistoryWithDeepEntryIface_raise_toY(&handle);
  57. shallowHistoryWithDeepEntry_runCycle(&handle);
  58. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Y));
  59. shallowHistoryWithDeepEntryIface_raise_toZ(&handle);
  60. shallowHistoryWithDeepEntry_runCycle(&handle);
  61. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B__region0_C));
  62. EXPECT_TRUE(shallowHistoryWithDeepEntry_isStateActive(&handle, ShallowHistoryWithDeepEntry_main_region_Z__region0_B));
  63. }