StatechartActiveTest.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 "gtest/gtest.h"
  12. #include "StatechartActive.h"
  13. StatechartActive handle;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. statechartActive_init(&handle);
  18. }
  19. };
  20. TEST_F(StatemachineTest, inactiveBeforeEnter) {
  21. EXPECT_TRUE(!statechartActive_isActive(&handle));
  22. }
  23. TEST_F(StatemachineTest, activeAfterEnter) {
  24. statechartActive_enter(&handle);
  25. EXPECT_TRUE(statechartActive_isActive(&handle));
  26. }
  27. TEST_F(StatemachineTest, inactiveAfterExit) {
  28. statechartActive_enter(&handle);
  29. statechartActive_exit(&handle);
  30. EXPECT_TRUE(!statechartActive_isActive(&handle));
  31. }
  32. TEST_F(StatemachineTest, activeAfterReenter) {
  33. statechartActive_enter(&handle);
  34. statechartActive_exit(&handle);
  35. statechartActive_enter(&handle);
  36. EXPECT_TRUE(statechartActive_isActive(&handle));
  37. }