ExitStateTest.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 "ExitState.h"
  14. TEST(StatemachineTest, defaultExit) {
  15. ExitState* statechart = new ExitState();
  16. statechart->init();
  17. statechart->enter();
  18. EXPECT_TRUE(statechart->isActive(ExitState::r_A));
  19. statechart->raise_e();
  20. statechart->runCycle();
  21. EXPECT_TRUE(statechart->isActive(ExitState::r_E));
  22. delete statechart;
  23. }
  24. TEST(StatemachineTest, namedExitThroughNamedTransition) {
  25. ExitState* statechart = new ExitState();
  26. statechart->init();
  27. statechart->enter();
  28. EXPECT_TRUE(statechart->isActive(ExitState::r_A));
  29. statechart->raise_f();
  30. statechart->runCycle();
  31. EXPECT_TRUE(statechart->isActive(ExitState::r_F));
  32. delete statechart;
  33. }
  34. TEST(StatemachineTest, namedExitThroughDefaultTransition) {
  35. ExitState* statechart = new ExitState();
  36. statechart->init();
  37. statechart->enter();
  38. EXPECT_TRUE(statechart->isActive(ExitState::r_A));
  39. statechart->raise_g();
  40. statechart->runCycle();
  41. EXPECT_TRUE(statechart->isActive(ExitState::r_E));
  42. delete statechart;
  43. }
  44. TEST(StatemachineTest, remainInA) {
  45. ExitState* statechart = new ExitState();
  46. statechart->init();
  47. statechart->enter();
  48. EXPECT_TRUE(statechart->isActive(ExitState::r_A));
  49. statechart->runCycle();
  50. EXPECT_TRUE(statechart->isActive(ExitState::r_A));
  51. delete statechart;
  52. }