DeepHistoryTest.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 "DeepHistory.h"
  13. static DeepHistory statechart;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. deepHistory_init(&statechart);
  18. }
  19. };
  20. TEST_F(StatemachineTest, deepHistoryTest) {
  21. deepHistory_enter(&statechart);
  22. deepHistoryIface_raise_event1(&statechart);
  23. deepHistory_runCycle(&statechart);
  24. deepHistoryIface_raise_event3(&statechart);
  25. deepHistory_runCycle(&statechart);
  26. deepHistoryIface_raise_event5(&statechart);
  27. deepHistory_runCycle(&statechart);
  28. deepHistoryIface_raise_event7(&statechart);
  29. deepHistory_runCycle(&statechart);
  30. EXPECT_TRUE(!deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State1));
  31. EXPECT_TRUE(deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  32. deepHistoryIface_raise_event2(&statechart);
  33. deepHistory_runCycle(&statechart);
  34. EXPECT_TRUE(deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State1));
  35. EXPECT_TRUE(!deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  36. deepHistoryIface_raise_event1(&statechart);
  37. deepHistory_runCycle(&statechart);
  38. EXPECT_TRUE(!deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State1));
  39. EXPECT_TRUE(deepHistory_isStateActive(&statechart, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  40. }