EntryExitSelfTransitionTest.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Copyright (c) 2014 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 "EntryExitSelfTransition.h"
  14. TEST(StatemachineTest, SelfTransitionToChildState) {
  15. EntryExitSelfTransition* statechart = new EntryExitSelfTransition();
  16. statechart->init();
  17. statechart->enter();
  18. statechart->runCycle();
  19. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 1);
  20. EXPECT_TRUE(statechart->isActive(EntryExitSelfTransition::B));
  21. statechart->getDefaultSCI()->set_entries(0);
  22. statechart->raise_e();
  23. statechart->runCycle();
  24. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 1);
  25. EXPECT_TRUE(statechart->getDefaultSCI()->get_exits()== 1);
  26. EXPECT_TRUE(statechart->isActive(EntryExitSelfTransition::C));
  27. delete statechart;
  28. }
  29. TEST(StatemachineTest, SelfTransitionFromChildState) {
  30. EntryExitSelfTransition* statechart = new EntryExitSelfTransition();
  31. statechart->init();
  32. statechart->enter();
  33. statechart->runCycle();
  34. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 1);
  35. statechart->getDefaultSCI()->set_entries(0);
  36. statechart->raise_e1();
  37. statechart->runCycle();
  38. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 0);
  39. EXPECT_TRUE(statechart->getDefaultSCI()->get_exits()== 0);
  40. EXPECT_TRUE(statechart->isActive(EntryExitSelfTransition::C));
  41. statechart->raise_e1();
  42. statechart->runCycle();
  43. EXPECT_TRUE(statechart->isActive(EntryExitSelfTransition::B));
  44. EXPECT_TRUE(statechart->getDefaultSCI()->get_entries()== 1);
  45. EXPECT_TRUE(statechart->getDefaultSCI()->get_exits()== 1);
  46. delete statechart;
  47. }