EnterStateTest.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 "EnterState.h"
  13. static EnterState statechart;
  14. class StatemachineTest : public ::testing::Test{
  15. protected:
  16. virtual void SetUp() {
  17. enterState_init(&statechart);
  18. }
  19. };
  20. TEST_F(StatemachineTest, defaultEntry) {
  21. enterState_enter(&statechart);
  22. EXPECT_TRUE(enterState_isStateActive(&statechart, EnterState_r_A));
  23. enterStateIface_raise_e(&statechart);
  24. enterState_runCycle(&statechart);
  25. EXPECT_TRUE(enterState_isStateActive(&statechart, EnterState_r_B_r_E));
  26. }
  27. TEST_F(StatemachineTest, namedEntryThroughNamedTransition) {
  28. enterState_enter(&statechart);
  29. EXPECT_TRUE(enterState_isStateActive(&statechart, EnterState_r_A));
  30. enterStateIface_raise_f(&statechart);
  31. enterState_runCycle(&statechart);
  32. EXPECT_TRUE(enterState_isStateActive(&statechart, EnterState_r_B_r_F));
  33. }
  34. TEST_F(StatemachineTest, namedEntryThroughDefaultTransition) {
  35. enterState_enter(&statechart);
  36. EXPECT_TRUE(enterState_isStateActive(&statechart, EnterState_r_A));
  37. enterStateIface_raise_g(&statechart);
  38. enterState_runCycle(&statechart);
  39. EXPECT_TRUE(enterState_isStateActive(&statechart, EnterState_r_B_r_E));
  40. }