ShallowHistory.cc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright (c) 2013 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 "ShallowHistory.h"
  14. TEST(StatemachineTest, shallowHistoryTest) {
  15. ShallowHistory handle;
  16. shallowHistory_init(&handle);
  17. shallowHistory_enter(&handle);
  18. shallowHistoryIface_raise_event1(&handle);
  19. shallowHistory_runCycle(&handle);
  20. shallowHistoryIface_raise_event3(&handle);
  21. shallowHistory_runCycle(&handle);
  22. shallowHistoryIface_raise_event5(&handle);
  23. shallowHistory_runCycle(&handle);
  24. shallowHistoryIface_raise_event7(&handle);
  25. shallowHistory_runCycle(&handle);
  26. EXPECT_TRUE(!shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State1));
  27. EXPECT_TRUE(shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  28. shallowHistoryIface_raise_event6(&handle);
  29. shallowHistory_runCycle(&handle);
  30. EXPECT_TRUE(!shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  31. EXPECT_TRUE(shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State6));
  32. shallowHistoryIface_raise_event5(&handle);
  33. shallowHistory_runCycle(&handle);
  34. EXPECT_TRUE(!shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State8));
  35. EXPECT_TRUE(shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  36. shallowHistoryIface_raise_event2(&handle);
  37. shallowHistory_runCycle(&handle);
  38. EXPECT_TRUE(!shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  39. EXPECT_TRUE(shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State1));
  40. shallowHistoryIface_raise_event1(&handle);
  41. shallowHistory_runCycle(&handle);
  42. EXPECT_TRUE(shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State6));
  43. EXPECT_TRUE(!shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State1));
  44. shallowHistoryIface_raise_event5(&handle);
  45. shallowHistory_runCycle(&handle);
  46. EXPECT_TRUE(!shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State6));
  47. EXPECT_TRUE(shallowHistory_isActive(&handle, ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  48. }