StatechartActiveTest.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <string>
  12. #include "gtest/gtest.h"
  13. #include "StatechartActive.h"
  14. #include "sc_types.h"
  15. StatechartActive* statechart;
  16. class StatemachineTest : public ::testing::Test{
  17. protected:
  18. virtual void SetUp() {
  19. statechart = new StatechartActive();
  20. statechart->init();
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. }
  25. };
  26. TEST_F(StatemachineTest, inactiveBeforeEnter) {
  27. EXPECT_TRUE(!statechart->isActive());
  28. }
  29. TEST_F(StatemachineTest, activeAfterEnter) {
  30. statechart->enter();
  31. EXPECT_TRUE(statechart->isActive());
  32. }
  33. TEST_F(StatemachineTest, inactiveAfterExit) {
  34. statechart->enter();
  35. statechart->exit();
  36. EXPECT_TRUE(!statechart->isActive());
  37. }
  38. TEST_F(StatemachineTest, activeAfterReenter) {
  39. statechart->enter();
  40. statechart->exit();
  41. statechart->enter();
  42. EXPECT_TRUE(statechart->isActive());
  43. }