GuardedExitTest.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 "GuardedExit.h"
  14. TEST(StatemachineTest, ExitTaken) {
  15. GuardedExit* statechart = new GuardedExit();
  16. statechart->init();
  17. statechart->enter();
  18. EXPECT_TRUE(statechart->isActive(GuardedExit::A));
  19. EXPECT_TRUE(!statechart->getSCInterface()->get_guard());
  20. statechart->raise_e();
  21. statechart->runCycle();
  22. EXPECT_TRUE(statechart->isActive(GuardedExit::B));
  23. EXPECT_TRUE(!statechart->getSCInterface()->get_done());
  24. delete statechart;
  25. }
  26. TEST(StatemachineTest, ExitNotTaken) {
  27. GuardedExit* statechart = new GuardedExit();
  28. statechart->init();
  29. statechart->enter();
  30. EXPECT_TRUE(statechart->isActive(GuardedExit::A));
  31. statechart->getSCInterface()->set_guard(true);
  32. statechart->raise_e();
  33. statechart->runCycle();
  34. EXPECT_TRUE(statechart->isActive(GuardedExit::B));
  35. EXPECT_TRUE(statechart->getSCInterface()->get_done());
  36. delete statechart;
  37. }