EnterState.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Copyright (c) 2013 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 "EnterState.h"
  14. TEST(StatemachineTest, defaultEntry) {
  15. EnterState handle;
  16. enterState_init(&handle);
  17. enterState_enter(&handle);
  18. EXPECT_TRUE(enterState_isActive(&handle, EnterState_r_A));
  19. enterStateIface_raise_e(&handle);
  20. enterState_runCycle(&handle);
  21. EXPECT_TRUE(enterState_isActive(&handle, EnterState_r_B_r_E));
  22. }
  23. TEST(StatemachineTest, namedEntryThroughNamedTransition) {
  24. EnterState handle;
  25. enterState_init(&handle);
  26. enterState_enter(&handle);
  27. EXPECT_TRUE(enterState_isActive(&handle, EnterState_r_A));
  28. enterStateIface_raise_f(&handle);
  29. enterState_runCycle(&handle);
  30. EXPECT_TRUE(enterState_isActive(&handle, EnterState_r_B_r_F));
  31. }
  32. TEST(StatemachineTest, namedEntryThroughDefaultTransition) {
  33. EnterState handle;
  34. enterState_init(&handle);
  35. enterState_enter(&handle);
  36. EXPECT_TRUE(enterState_isActive(&handle, EnterState_r_A));
  37. enterStateIface_raise_g(&handle);
  38. enterState_runCycle(&handle);
  39. EXPECT_TRUE(enterState_isActive(&handle, EnterState_r_B_r_E));
  40. }