DeepHistory.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Copyright (c) 2015 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 "DeepHistory.h"
  14. DeepHistory handle;
  15. TEST(StatemachineTest, deepHistoryTest) {
  16. deepHistory_init(&handle);
  17. deepHistory_enter(&handle);
  18. deepHistoryIface_raise_event1(&handle);
  19. deepHistory_runCycle(&handle);
  20. deepHistoryIface_raise_event3(&handle);
  21. deepHistory_runCycle(&handle);
  22. deepHistoryIface_raise_event5(&handle);
  23. deepHistory_runCycle(&handle);
  24. deepHistoryIface_raise_event7(&handle);
  25. deepHistory_runCycle(&handle);
  26. EXPECT_TRUE(!deepHistory_isStateActive(&handle, DeepHistory_mainRegion_State1));
  27. EXPECT_TRUE(deepHistory_isStateActive(&handle, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  28. deepHistoryIface_raise_event2(&handle);
  29. deepHistory_runCycle(&handle);
  30. EXPECT_TRUE(deepHistory_isStateActive(&handle, DeepHistory_mainRegion_State1));
  31. EXPECT_TRUE(!deepHistory_isStateActive(&handle, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  32. deepHistoryIface_raise_event1(&handle);
  33. deepHistory_runCycle(&handle);
  34. EXPECT_TRUE(!deepHistory_isStateActive(&handle, DeepHistory_mainRegion_State1));
  35. EXPECT_TRUE(deepHistory_isStateActive(&handle, DeepHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9));
  36. }